fix thread compilation issue for windows
This commit is contained in:
@@ -10,9 +10,12 @@ target_include_directories(sudoku_demo_renderer PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
# Link pthread for std::thread
|
||||
# Link threading library for std::thread (platform-specific)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(sudoku_demo_renderer Threads::Threads)
|
||||
if(Threads_FOUND)
|
||||
target_link_libraries(sudoku_demo_renderer Threads::Threads)
|
||||
endif()
|
||||
|
||||
# Set C++17 standard
|
||||
set_target_properties(sudoku_demo_renderer PROPERTIES
|
||||
|
||||
@@ -35,6 +35,10 @@ else()
|
||||
message(WARNING "Google Benchmark not found. Benchmarks will not be built.")
|
||||
endif()
|
||||
|
||||
# Find threading library for platform-specific threading support
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads)
|
||||
|
||||
# Create the main executable
|
||||
add_executable(sudoku_demo
|
||||
main.cpp
|
||||
@@ -119,7 +123,10 @@ if(HAS_GTEST)
|
||||
test_sudoku.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(sudoku_tests GTest::gtest GTest::gtest_main nd-wfc pthread)
|
||||
target_link_libraries(sudoku_tests GTest::gtest GTest::gtest_main nd-wfc)
|
||||
if(Threads_FOUND)
|
||||
target_link_libraries(sudoku_tests Threads::Threads)
|
||||
endif()
|
||||
|
||||
# Set test output directory
|
||||
set_target_properties(sudoku_tests PROPERTIES
|
||||
@@ -142,7 +149,10 @@ if(HAS_BENCHMARK)
|
||||
benchmark_sudoku.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(sudoku_benchmarks benchmark::benchmark nd-wfc pthread)
|
||||
target_link_libraries(sudoku_benchmarks benchmark::benchmark nd-wfc)
|
||||
if(Threads_FOUND)
|
||||
target_link_libraries(sudoku_benchmarks Threads::Threads)
|
||||
endif()
|
||||
|
||||
# Set benchmark output directory
|
||||
set_target_properties(sudoku_benchmarks PROPERTIES
|
||||
|
||||
Reference in New Issue
Block a user