diff --git a/CMakeLists.txt b/CMakeLists.txt index 20cd986..c80c2b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,13 +46,13 @@ endfunction() function(add_static_flag target_name) if (MCPPPP_STATIC_LINK AND (NOT MSVC) AND (NOT APPLE)) # Doesn't seem to work on mac, hopefully will be fixed - target_link_libraries(${target_name} "-static") + target_link_libraries(${target_name} PRIVATE "-static") endif () endfunction() if (MCPPPP_CLI) add_executable(MCPPPP-cli "src/Source.cpp" "src/fsb.cpp" "src/vmt.cpp" "src/cim.cpp" "src/utility.cpp") - target_link_libraries(MCPPPP-cli lodepng microtar fmt) + target_link_libraries(MCPPPP-cli PRIVATE lodepng microtar fmt) add_static_flag(MCPPPP-cli) add_mp_flag(MCPPPP-cli) endif () @@ -70,9 +70,13 @@ if (MCPPPP_GUI) endif () add_executable(MCPPPP-gui "src/Source.cpp" "src/fsb.cpp" "src/vmt.cpp" "src/cim.cpp" "src/utility.cpp" "src/fl_impl.cpp" "src/gui.cpp" "src/mcpppp.cxx") target_compile_definitions(MCPPPP-gui PUBLIC "GUI") - target_link_libraries(MCPPPP-gui lodepng microtar fmt fltk) + target_link_libraries(MCPPPP-gui PRIVATE lodepng microtar fmt fltk) + # I guess this is needed? + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries(MCPPPP-gui PRIVATE Threads::Threads) if (APPLE) - target_link_libraries(MCPPPP-gui "-framework Cocoa") + target_link_libraries(MCPPPP-gui PRIVATE "-framework Cocoa") endif () # No static link for gui (for now) add_mp_flag(MCPPPP-gui) @@ -84,7 +88,7 @@ if (MCPPPP_JNI) include_directories("${JNI_INCLUDE_DIRS}") add_library(mcpppp SHARED "src/jni.cpp" "src/fsb.cpp" "src/vmt.cpp" "src/cim.cpp" "src/utility.cpp") set_property(TARGET mcpppp PROPERTY POSITION_INDEPENDENT_CODE TRUE) - target_link_libraries(mcpppp lodepng microtar fmt) + target_link_libraries(mcpppp PRIVATE lodepng microtar fmt) add_static_flag(mcpppp) add_mp_flag(mcpppp) else () @@ -96,9 +100,9 @@ if (MCPPPP_WEB) if (EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".html") add_executable(MCPPPP-web "src/Source.cpp" "src/fsb.cpp" "src/vmt.cpp" "src/cim.cpp" "src/utility.cpp" "src/em_impl.cpp") - target_link_libraries(MCPPPP-web lodepng microtar fmt) + target_link_libraries(MCPPPP-web PRIVATE lodepng microtar fmt) target_compile_options(MCPPPP-web PRIVATE -sDISABLE_EXCEPTION_CATCHING=0 -pthread) - target_link_libraries(MCPPPP-web "embind" "--shell-file ${CMAKE_SOURCE_DIR}/src/template.html" "-s EXIT_RUNTIME=0" "-s ALLOW_MEMORY_GROWTH" "-s DISABLE_EXCEPTION_CATCHING=0" "-pthread" "-s PTHREAD_POOL_SIZE=1") + target_link_libraries(MCPPPP-web PRIVATE "embind" "--shell-file ${CMAKE_SOURCE_DIR}/src/template.html" "-s EXIT_RUNTIME=0" "-s ALLOW_MEMORY_GROWTH" "-s DISABLE_EXCEPTION_CATCHING=0" "-pthread" "-s PTHREAD_POOL_SIZE=1") else () message(SEND_ERROR "Web version must be compiled using emscripten (emcmake)") endif ()