Setup and clear of string pool.
[SquirrelJME.git] / nanocoat / cmake / threads.cmake
blob401b4c83009e887b5fc8d69f6e6d7bd089b8ced4
1 # ---------------------------------------------------------------------------
2 # SquirrelJME
3 #     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
4 # ---------------------------------------------------------------------------
5 # SquirrelJME is under the Mozilla Public License Version 2.0.
6 # See license.mkd for licensing and copyright information.
7 # ---------------------------------------------------------------------------
8 # DESCRIPTION: Threading and atomics support
10 # For compatibility for Windows, do not use pthreads even if available
11 find_package(Threads)
12 if(WIN32)
13         add_compile_definitions(SJME_CONFIG_HAS_THREADS=1)
14         add_compile_definitions(SJME_CONFIG_HAS_THREADS_WIN32=1)
15 elseif(Threads_FOUND)
16         if(CMAKE_USE_PTHREADS_INIT)
17                 # Does pthread actually exist?
18                 try_compile(SQUIRRELJME_PTHREADS_TRY_VALID
19                         "${CMAKE_CURRENT_BINARY_DIR}"
20                         SOURCES "${CMAKE_CURRENT_LIST_DIR}/tryPThread.c"
21                         CMAKE_FLAGS "-DCMAKE_TRY_COMPILE_TARGET_TYPE=EXECUTABLE"
22                         LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}
23                         OUTPUT_VARIABLE SQUIRRELJME_PTHREADS_TRY_OUTPUT)
24                 message("PThread: ${SQUIRRELJME_PTHREADS_TRY_OUTPUT}")
26                 # Valid?
27                 if(SQUIRRELJME_PTHREADS_TRY_VALID)
28                         message("PThread: Valid!")
30                         add_compile_definitions(
31                                 SJME_CONFIG_HAS_THREADS=1)
32                         add_compile_definitions(
33                                 SJME_CONFIG_HAS_THREADS_PTHREAD=1)
35                         # Specific OSes?
36                         if (LINUX)
37                                 add_compile_definitions(
38                                         SJME_CONFIG_HAS_THREADS_PTHREAD_LINUX=1)
39                         elseif(APPLE OR BSD)
40                                 if(APPLE)
41                                         add_compile_definitions(
42                                                 SJME_CONFIG_HAS_THREADS_PTHREAD_MACOS=1)
43                                 endif()
45                                 add_compile_definitions(
46                                         SJME_CONFIG_HAS_THREADS_PTHREAD_BSD=1)
47                         endif()
48                 else()
49                         message("PThread: Not available or misconfigured.")
50                 endif()
51         endif()
52 endif()