소스 검색

link properly with pthreads library if needed

Ioannis Koutras 11 년 전
부모
커밋
c8ed718b86
3개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 0
      CMakeLists.txt
  2. 0 1
      examples/CMakeLists.txt
  3. 6 0
      src/CMakeLists.txt

+ 3 - 0
CMakeLists.txt

@@ -41,6 +41,9 @@ endif(WITH_SYSTEM_CALLS STREQUAL "mmap")
 if(NOT HAVE_LOCKS AND TRYLOCK_ON_MALLOC)
   message(FATAL_ERROR "You have to set HAVE_LOCKS to use TRYLOCK_ON_MALLOC.")
 endif(NOT HAVE_LOCKS AND TRYLOCK_ON_MALLOC)
+if(HAVE_LOCKS)
+  find_package(Threads)
+endif(HAVE_LOCKS)
 
 # Checking free-list setups
 if(RAW_BLOCKS_TYPE STREQUAL "freelist")

+ 0 - 1
examples/CMakeLists.txt

@@ -7,7 +7,6 @@ include_directories(
 set(CMAKE_BUILD_TYPE Debug)
 
 if (HAVE_LOCKS)
-  find_package (Threads)
   add_executable(larson larson.c)
   target_link_libraries(larson ${CMAKE_THREAD_LIBS_INIT} ${DMMLIB_SHARED_LIBRARY})
 endif (HAVE_LOCKS)

+ 6 - 0
src/CMakeLists.txt

@@ -238,6 +238,9 @@ include_directories(
 
 if (WITH_SHARED_LIB)
   add_library(${DMMLIB_SHARED_LIBRARY} SHARED ${dmmlib_SRCS})
+  if(HAVE_LOCKS)
+    target_link_libraries(${DMMLIB_SHARED_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
+  endif(HAVE_LOCKS)
 
   set_target_properties(
     ${DMMLIB_SHARED_LIBRARY}
@@ -260,6 +263,9 @@ endif (WITH_SHARED_LIB)
 
 if (WITH_STATIC_LIB)
   add_library(${DMMLIB_STATIC_LIBRARY} STATIC ${dmmlib_SRCS})
+  if(HAVE_LOCKS)
+    target_link_libraries(${DMMLIB_STATIC_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
+  endif(HAVE_LOCKS)
 
   set_target_properties(
     ${DMMLIB_STATIC_LIBRARY}