Skip to content

Commit

Permalink
* better atomic linking checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Feb 12, 2015
1 parent 021bc3d commit f811dd5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ai/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include(CheckFunctionExists)
include(CheckLibraryExists)

file(GLOB_RECURSE SRC *.cpp *.h)

set(DEPS ${CMAKE_THREAD_LIBS_INIT} ${GOOGLE_PROFILER_LIB} ${GOOGLE_TCMALLOC_LIB})
Expand Down Expand Up @@ -45,7 +48,7 @@ elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
if (NOT HAVE___ATOMIC_FETCH_ADD_4)
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
if (HAVE_LIBATOMIC)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
list(APPEND DEPS "-latomic")
endif()
endif()
endif()
Expand Down
17 changes: 16 additions & 1 deletion src/run/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include(CheckFunctionExists)
include(CheckLibraryExists)

if (SIMPLEAI_RUN)
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
Expand All @@ -11,5 +14,17 @@ if (SIMPLEAI_RUN)
link_directories(${SIMPLEAI_BINARY_DIR}/src/ai)
file(GLOB_RECURSE SRC ${SIMPLEAI_SOURCE_DIR}/src/run/*.cpp ${SIMPLEAI_SOURCE_DIR}/src/run/*.h)
add_executable(simpleai-run ${SRC})
target_link_libraries(simpleai-run simpleai ${CMAKE_THREAD_LIBS_INIT} -latomic ${GOOGLE_PROFILER_LIB} ${GOOGLE_TCMALLOC_LIB})
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
check_function_exists(__atomic_fetch_add_4 HAVE___ATOMIC_FETCH_ADD_4)
if (NOT HAVE___ATOMIC_FETCH_ADD_4)
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
if (HAVE_LIBATOMIC)
list(APPEND DEPS "-latomic")
endif()
endif()
endif()

target_link_libraries(simpleai-run simpleai ${CMAKE_THREAD_LIBS_INIT} ${DEPS} ${GOOGLE_PROFILER_LIB} ${GOOGLE_TCMALLOC_LIB})
endif()

0 comments on commit f811dd5

Please sign in to comment.