From 292d35879b73658c6d94d09db35ac1bfe97bb97e Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 5 Aug 2016 04:07:01 -0400 Subject: [PATCH] build: restore mingw support --- CMakeLists.txt | 7 ++++++- cmake/ubuntu-mingw-cross.cmake | 19 +++++++++++++++++++ common/threads.c | 4 ++-- light/CMakeLists.txt | 9 ++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 cmake/ubuntu-mingw-cross.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 36f18a05..3b3c9153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,9 @@ find_package (Threads) if (CMAKE_USE_PTHREADS_INIT) add_definitions(-DUSE_PTHREADS) -endif (CMAKE_USE_PTHREADS_INIT) +elseif (CMAKE_USE_WIN32_THREADS_INIT) + add_definitions(-DUSE_WIN32THREADS) +endif () # (see http://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/) if (MINGW) @@ -40,6 +42,9 @@ if (UNIX) add_definitions(-DLINUX) endif (UNIX) +set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}") +set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}") + add_definitions(-DTYRUTILS_VERSION=${GIT_DESCRIBE}) #minimum version that supports unordered_map diff --git a/cmake/ubuntu-mingw-cross.cmake b/cmake/ubuntu-mingw-cross.cmake new file mode 100644 index 00000000..7fcc78c0 --- /dev/null +++ b/cmake/ubuntu-mingw-cross.cmake @@ -0,0 +1,19 @@ +# based on http://www.vtk.org/Wiki/CmakeMingw + +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) +SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/common/threads.c b/common/threads.c index a12ee549..81380de0 100644 --- a/common/threads.c +++ b/common/threads.c @@ -74,7 +74,7 @@ InterruptThreadProgress__(void) * WIN32 * =================================================================== */ -#ifdef WIN32 +#ifdef USE_WIN32THREADS #define HAVE_THREADS #include @@ -159,7 +159,7 @@ RunThreadsOn(int start, int workcnt, void *(func)(void *), void *arg) free(threadid); } -#endif /* WIN32 */ +#endif /* USE_WIN32THREADS */ /* * =================================================================== diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index cb49c3a5..2e12be3f 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -41,9 +41,12 @@ endif(embree_FOUND) add_executable(light ${LIGHT_SOURCES}) target_link_libraries (light ${CMAKE_THREAD_LIBS_INIT}) -set_property(TARGET light PROPERTY CXX_STANDARD 11) -set_property(TARGET light PROPERTY CXX_STANDARD_REQUIRED ON) -set_property(TARGET light PROPERTY C_STANDARD 99) +#set_property(TARGET light PROPERTY CXX_STANDARD 11) +#set_property(TARGET light PROPERTY CXX_STANDARD_REQUIRED ON) +#set_property(TARGET light PROPERTY C_STANDARD 99) + +#set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}") +#set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}") if (embree_FOUND) target_link_libraries (light ${EMBREE_LIBRARY})