From 32a37acd5a288a953ecfc6fc76d006119e9cd048 Mon Sep 17 00:00:00 2001 From: Raymonf Date: Thu, 20 Aug 2020 17:47:27 -0400 Subject: [PATCH] Update CMakeLists to use correct binary name and pthreads if not using MinGW/VS --- CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e02ae6e..b6a8c69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,11 +17,23 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Set the OpenFusion project as the default startup project for VS set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT openfusion) +if (WIN32) + # Set the output binary name to winfusion to match the regular Makefile + set(BIN_NAME winfusion) +else() + set(BIN_NAME fusion) +endif() + include_directories(src) file(GLOB_RECURSE SOURCES src/**.cpp src/**.hpp) add_executable(openfusion ${SOURCES}) -# Set the output binary name to winfusion to match the regular Makefile -set_target_properties(openfusion PROPERTIES OUTPUT_NAME winfusion) +set_target_properties(openfusion PROPERTIES OUTPUT_NAME ${BIN_NAME}) + +# Use pthreads if not generating a VS solution or MinGW makefile (because MinGW will prefer Win32 threads) +if (NOT CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_GENERATOR MATCHES "MinGW Makefiles") + find_package(Threads REQUIRED) + target_link_libraries(openfusion pthread) +endif() \ No newline at end of file