ref: 5546ffcf2e737d2f12fce96a98e7c1ac4edf4333
parent: 8fd74cea1b1dda245797096d4236c5fdf86725ce
author: Ing. Radomír Polách <rp@t4d.cz>
date: Mon Sep 5 19:29:39 EDT 2016
fix: mingw build
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,7 +36,11 @@
add_definitions(-DCONFIG_BLOCK_DEV_CACHE_SIZE=16)
else()
#Generic example target
- set(BLOCKDEV_TYPE linux)
+ if (WIN32)
+ set(BLOCKDEV_TYPE windows)
+ else()
+ set(BLOCKDEV_TYPE linux)
+ endif()
set (INSTALL_LIB 1)
add_definitions(-DCONFIG_HAVE_OWN_OFLAGS=0)
add_definitions(-DCONFIG_HAVE_OWN_ERRNO=0)
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,13 @@
$(COMMON_DEFINITIONS) \
-DCMAKE_TOOLCHAIN_FILE=../toolchain/generic.cmake ..
+mingw:
+ rm -R -f build_mingw
+ mkdir build_mingw
+ cd build_mingw && cmake -G"Unix Makefiles" \
+ $(COMMON_DEFINITIONS) \
+ -DWIN32=1 \
+ -DCMAKE_TOOLCHAIN_FILE=../toolchain/mingw.cmake ..
avrxmega7:
rm -R -f build_avrxmega7
--- a/blockdev/CMakeLists.txt
+++ b/blockdev/CMakeLists.txt
@@ -1,9 +1,10 @@
#Blockdev library
-if (BLOCKDEV_TYPE STREQUAL linux)
-aux_source_directory(linux BLOCKDEV_SRC)
-elseif (BLOCKDEV_TYPE STREQUAL windows)
-aux_source_directory(windows BLOCKDEV_SRC)
+if (WIN32)
+ aux_source_directory(linux BLOCKDEV_SRC)
+ aux_source_directory(windows BLOCKDEV_SRC)
+elseif (BLOCKDEV_TYPE STREQUAL linux)
+ aux_source_directory(linux BLOCKDEV_SRC)
else()
endif()
--- /dev/null
+++ b/toolchain/mingw.cmake
@@ -1,0 +1,32 @@
+# Name of the target
+set(CMAKE_SYSTEM_NAME Windows)
+set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
+set(CMAKE_SYSTEM_PROCESSOR mingw)
+
+# Toolchain settings
+set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+set(AS ${TOOLCHAIN_PREFIX}-as)
+set(AR ${TOOLCHAIN_PREFIX}-as)
+set(OBJCOPY objcopy)
+set(OBJDUMP objdump)
+set(SIZE size)
+
+set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+
+set(CMAKE_C_FLAGS "-std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
+set(CMAKE_CXX_FLAGS "-fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
+set(CMAKE_ASM_FLAGS "" CACHE INTERNAL "asm compiler flags")
+if (APPLE)
+ set(CMAKE_EXE_LINKER_FLAGS "-dead_strip" CACHE INTERNAL "exe link flags")
+else (APPLE)
+ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections" CACHE INTERNAL "exe link flags")
+endif (APPLE)
+
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")
+SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")
+
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -g -ggdb3" CACHE INTERNAL "c release compiler flags")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g -ggdb3" CACHE INTERNAL "cxx release compiler flags")
+SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")