diff options
| author | Ahmad Fatoum <ahmad@a3f.at> | 2019-05-04 19:36:16 +0200 |
|---|---|---|
| committer | Ahmad Fatoum <ahmad@a3f.at> | 2019-05-04 21:23:41 +0200 |
| commit | 2cda760312eb9219f4e3d773209289696fec5f71 (patch) | |
| tree | 2e954be0f096eb803c0d9a0717be1bc65969819c /examples | |
| parent | 6681fd7df27e4229518f51dc4929e909d9e94917 (diff) | |
| download | raylib-2cda760312eb9219f4e3d773209289696fec5f71.tar.gz raylib-2cda760312eb9219f4e3d773209289696fec5f71.zip | |
examples: CMake: don't build core_loading_thread if no pthreads
The example requires pthreads and now C11 <stdatomic.h>, thus skip it
if either isn't available.
This also fixes the current Travis CI build failure for the
Windows configuration.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/CMakeLists.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 32d27ddc..5f0b0242 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,6 +28,24 @@ include(CheckIncludeFiles) set(OUTPUT_EXT) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) +include(CheckIncludeFile) +CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC_H) +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_package(Threads) +if (CMAKE_USE_PTHREADS_INIT AND HAVE_STDATOMIC_H) + add_if_flag_compiles("-std=c11" CMAKE_C_FLAGS) + if(THREADS_HAVE_PTHREAD_ARG) + add_if_flag_compiles("-pthread" CMAKE_C_FLAGS) + endif() + if(CMAKE_THREAD_LIBS_INIT) + link_libraries("${CMAKE_THREAD_LIBS_INIT}") + endif() +else() + # Items requiring pthreads + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_loading_thread.c) +endif() + + if(${PLATFORM} MATCHES "Android") list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c) |
