diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake/utils.cmake | 7 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 12 |
3 files changed, 16 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ed230aa..67087b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,10 @@ else() message(STATUS "Configuring Effcee to avoid building samples.") endif() +# RE2 needs Pthreads on non-WIN32 +set(CMAKE_THREAD_LIBS_INIT "") +find_package(Threads) + include(cmake/setup_build.cmake) include(cmake/utils.cmake) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 727b7ea..291be3c 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -17,9 +17,6 @@ function(effcee_default_c_compile_options TARGET) if (NOT "${MSVC}") target_compile_options(${TARGET} PRIVATE -Wall -Werror) - if (UNIX) - target_compile_options(${TARGET} PUBLIC -pthread) - endif(UNIX) if (ENABLE_CODE_COVERAGE) # The --coverage option is a synonym for -fprofile-arcs -ftest-coverage # when compiling. @@ -37,7 +34,9 @@ function(effcee_default_c_compile_options TARGET) LINK_FLAGS "-static -static-libgcc") endif(WIN32) endif(NOT EFFCEE_ENABLE_SHARED_CRT) - target_link_libraries(${TARGET} PUBLIC ${CMAKE_THREAD_LIBS_INIT}) + if (UNIX AND NOT MINGW) + target_link_libraries(${TARGET} PUBLIC -pthread) + endif() else() # disable warning C4800: 'int' : forcing value to bool 'true' or 'false' # (performance warning) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 47a326c..32cdd29 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,9 +1,15 @@ add_executable(effcee-example main.cc) target_link_libraries(effcee-example effcee) -if(UNIX) - target_link_libraries(effcee-example -pthread) -endif(UNIX) +if(UNIX AND NOT MINGW) + set_target_properties(effcee-example PROPERTIES LINK_FLAGS -pthread) +endif() +if (WIN32 AND NOT MSVC) + # For MinGW cross-compile, statically link to the C++ runtime + set_target_properties(effcee-example PROPERTIES + LINK_FLAGS "-static -static-libgcc -static-libstdc++") +endif(WIN32 AND NOT MSVC) + if(EFFCEE_BUILD_TESTING) add_test(NAME effcee-example |