Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
fix cmake pthread thingy?
Browse files Browse the repository at this point in the history
  • Loading branch information
supsm committed Nov 1, 2022
1 parent ecc7ffc commit b79f183
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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)
Expand All @@ -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 ()
Expand All @@ -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 ()
Expand Down

0 comments on commit b79f183

Please sign in to comment.