Permalink
Browse files

added pthread dependency to CMake project files, fixes #65

  • Loading branch information...
1 parent 8fddc52 commit e63cd5e055114dcef38d9d90823b9575d0918b46 @Neverlord Neverlord committed Aug 30, 2012
View
5 CMakeLists.txt
@@ -156,13 +156,14 @@ if (NOT DISABLE_CONTEXT_SWITCHING)
endif ()
find_package(Boost REQUIRED)
+find_package(PTHREAD REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
-include_directories(. ${Boost_INCLUDE_DIRS} ${boost_context}/include)
+include_directories(. ${Boost_INCLUDE_DIRS} ${boost_context}/include ${PTHREAD_INCLUDE_DIR})
add_library(libcppa SHARED ${LIBCPPA_SRC})
-target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY})
+target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY} ${PTHREAD_LIBRARIES})
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
View
56 FindPTHREAD.cmake
@@ -0,0 +1,56 @@
+# - Find pthread
+# Find the native PTHREAD headers and libraries.
+#
+# PTHREAD_INCLUDE_DIR - where to find pthread.h, etc.
+# PTHREAD_LIBRARIES - List of libraries when using pthread.
+# PTHREAD_FOUND - True if pthread found.
+
+GET_FILENAME_COMPONENT(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH )
+
+# Look for the header file.
+FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/include
+ $ENV{H3D_EXTERNAL_ROOT}/include/pthread
+ $ENV{H3D_ROOT}/../External/include
+ $ENV{H3D_ROOT}/../External/include/pthread
+ ../../External/include
+ ../../External/include/pthread
+ ${module_file_path}/../../../External/include
+ ${module_file_path}/../../../External/include/pthread)
+
+MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIR)
+
+# Look for the library.
+
+IF(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthreadVC2
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/lib
+ $ENV{H3D_ROOT}/../External/lib
+ ../../External/lib
+ ${module_file_path}/../../../External/lib)
+ELSE(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
+ENDIF(WIN32)
+MARK_AS_ADVANCED(PTHREAD_LIBRARY)
+
+# Copy the results to the output variables.
+IF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 1)
+ SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
+ SET(PTHREAD_INCLUDE_DIR ${PTHREAD_INCLUDE_DIR})
+ELSE(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 0)
+ SET(PTHREAD_LIBRARIES)
+ SET(PTHREAD_INCLUDE_DIR)
+ENDIF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+
+# Report the results.
+IF(NOT PTHREAD_FOUND)
+ SET(PTHREAD_DIR_MESSAGE
+ "PTHREAD was not found. Make sure PTHREAD_LIBRARY and PTHREAD_INCLUDE_DIR are set. Pthread is required to compile.")
+ IF(PTHREAD_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "${PTHREAD_DIR_MESSAGE}")
+ ELSEIF(NOT PTHREAD_FIND_QUIETLY)
+ MESSAGE(STATUS "${PTHREAD_DIR_MESSAGE}")
+ ENDIF(PTHREAD_FIND_REQUIRED)
+ENDIF(NOT PTHREAD_FOUND)
View
7 benchmarks/CMakeLists.txt
@@ -15,12 +15,13 @@ if(NOT cppa_LIBRARY)
find_package(Libcppa REQUIRED)
endif (NOT cppa_LIBRARY)
-find_package(Boost COMPONENTS thread REQUIRED)
+find_package(Boost REQUIRED)
+find_package(PTHREAD REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
-include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
+include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR})
-set(benchmark_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
+set(benchmark_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY} ${PTHREAD_LIBRARIES})
target_link_libraries(actor_creation ${benchmark_LIBS})
target_link_libraries(mailbox_performance ${benchmark_LIBS})
View
56 benchmarks/FindPTHREAD.cmake
@@ -0,0 +1,56 @@
+# - Find pthread
+# Find the native PTHREAD headers and libraries.
+#
+# PTHREAD_INCLUDE_DIR - where to find pthread.h, etc.
+# PTHREAD_LIBRARIES - List of libraries when using pthread.
+# PTHREAD_FOUND - True if pthread found.
+
+GET_FILENAME_COMPONENT(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH )
+
+# Look for the header file.
+FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/include
+ $ENV{H3D_EXTERNAL_ROOT}/include/pthread
+ $ENV{H3D_ROOT}/../External/include
+ $ENV{H3D_ROOT}/../External/include/pthread
+ ../../External/include
+ ../../External/include/pthread
+ ${module_file_path}/../../../External/include
+ ${module_file_path}/../../../External/include/pthread)
+
+MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIR)
+
+# Look for the library.
+
+IF(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthreadVC2
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/lib
+ $ENV{H3D_ROOT}/../External/lib
+ ../../External/lib
+ ${module_file_path}/../../../External/lib)
+ELSE(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
+ENDIF(WIN32)
+MARK_AS_ADVANCED(PTHREAD_LIBRARY)
+
+# Copy the results to the output variables.
+IF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 1)
+ SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
+ SET(PTHREAD_INCLUDE_DIR ${PTHREAD_INCLUDE_DIR})
+ELSE(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 0)
+ SET(PTHREAD_LIBRARIES)
+ SET(PTHREAD_INCLUDE_DIR)
+ENDIF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+
+# Report the results.
+IF(NOT PTHREAD_FOUND)
+ SET(PTHREAD_DIR_MESSAGE
+ "PTHREAD was not found. Make sure PTHREAD_LIBRARY and PTHREAD_INCLUDE_DIR are set. Pthread is required to compile.")
+ IF(PTHREAD_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "${PTHREAD_DIR_MESSAGE}")
+ ELSEIF(NOT PTHREAD_FIND_QUIETLY)
+ MESSAGE(STATUS "${PTHREAD_DIR_MESSAGE}")
+ ENDIF(PTHREAD_FIND_REQUIRED)
+ENDIF(NOT PTHREAD_FOUND)
View
7 examples/CMakeLists.txt
@@ -21,12 +21,13 @@ if(NOT cppa_LIBRARY)
find_package(Libcppa REQUIRED)
endif (NOT cppa_LIBRARY)
-find_package(Boost COMPONENTS)
+find_package(Boost REQUIRED)
+find_package(PTHREAD REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
-include_directories(. ${CPPA_INCLUDE} ${Boost_INCLUDE_DIRS})
+include_directories(. ${CPPA_INCLUDE} ${Boost_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR})
-set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY})
+set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${PTHREAD_LIBRARIES})
target_link_libraries(announce_example_1 ${EXAMPLE_LIBS})
target_link_libraries(announce_example_2 ${EXAMPLE_LIBS})
View
56 examples/FindPTHREAD.cmake
@@ -0,0 +1,56 @@
+# - Find pthread
+# Find the native PTHREAD headers and libraries.
+#
+# PTHREAD_INCLUDE_DIR - where to find pthread.h, etc.
+# PTHREAD_LIBRARIES - List of libraries when using pthread.
+# PTHREAD_FOUND - True if pthread found.
+
+GET_FILENAME_COMPONENT(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH )
+
+# Look for the header file.
+FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/include
+ $ENV{H3D_EXTERNAL_ROOT}/include/pthread
+ $ENV{H3D_ROOT}/../External/include
+ $ENV{H3D_ROOT}/../External/include/pthread
+ ../../External/include
+ ../../External/include/pthread
+ ${module_file_path}/../../../External/include
+ ${module_file_path}/../../../External/include/pthread)
+
+MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIR)
+
+# Look for the library.
+
+IF(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthreadVC2
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/lib
+ $ENV{H3D_ROOT}/../External/lib
+ ../../External/lib
+ ${module_file_path}/../../../External/lib)
+ELSE(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
+ENDIF(WIN32)
+MARK_AS_ADVANCED(PTHREAD_LIBRARY)
+
+# Copy the results to the output variables.
+IF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 1)
+ SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
+ SET(PTHREAD_INCLUDE_DIR ${PTHREAD_INCLUDE_DIR})
+ELSE(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 0)
+ SET(PTHREAD_LIBRARIES)
+ SET(PTHREAD_INCLUDE_DIR)
+ENDIF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+
+# Report the results.
+IF(NOT PTHREAD_FOUND)
+ SET(PTHREAD_DIR_MESSAGE
+ "PTHREAD was not found. Make sure PTHREAD_LIBRARY and PTHREAD_INCLUDE_DIR are set. Pthread is required to compile.")
+ IF(PTHREAD_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "${PTHREAD_DIR_MESSAGE}")
+ ELSEIF(NOT PTHREAD_FIND_QUIETLY)
+ MESSAGE(STATUS "${PTHREAD_DIR_MESSAGE}")
+ ENDIF(PTHREAD_FIND_REQUIRED)
+ENDIF(NOT PTHREAD_FOUND)
View
8 unit_testing/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.6)
project(cppa_unit_tests CXX)
+
# set up environment paths to cmake modules and libcppa
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
@@ -12,15 +13,16 @@ endif (NOT cppa_LIBRARY)
#find_package(Boost COMPONENTS thread REQUIRED)
find_package(Boost REQUIRED)
+find_package(PTHREAD REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
-include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
+include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR})
-set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY})
+set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${PTHREAD_LIBRARIES})
macro(add_unit_test name)
add_executable(test__${name} test__${name}.cpp ${ARGN})
- target_link_libraries(test__${name} ${EXAMPLE_LIBS})
+ target_link_libraries(test__${name} ${EXAMPLE_LIBS} ${CMAKE_THREAD_LIBS_INIT})
add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/test__${name})
endmacro()
View
56 unit_testing/FindPTHREAD.cmake
@@ -0,0 +1,56 @@
+# - Find pthread
+# Find the native PTHREAD headers and libraries.
+#
+# PTHREAD_INCLUDE_DIR - where to find pthread.h, etc.
+# PTHREAD_LIBRARIES - List of libraries when using pthread.
+# PTHREAD_FOUND - True if pthread found.
+
+GET_FILENAME_COMPONENT(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH )
+
+# Look for the header file.
+FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/include
+ $ENV{H3D_EXTERNAL_ROOT}/include/pthread
+ $ENV{H3D_ROOT}/../External/include
+ $ENV{H3D_ROOT}/../External/include/pthread
+ ../../External/include
+ ../../External/include/pthread
+ ${module_file_path}/../../../External/include
+ ${module_file_path}/../../../External/include/pthread)
+
+MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIR)
+
+# Look for the library.
+
+IF(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthreadVC2
+ PATHS $ENV{H3D_EXTERNAL_ROOT}/lib
+ $ENV{H3D_ROOT}/../External/lib
+ ../../External/lib
+ ${module_file_path}/../../../External/lib)
+ELSE(WIN32)
+ FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
+ENDIF(WIN32)
+MARK_AS_ADVANCED(PTHREAD_LIBRARY)
+
+# Copy the results to the output variables.
+IF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 1)
+ SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
+ SET(PTHREAD_INCLUDE_DIR ${PTHREAD_INCLUDE_DIR})
+ELSE(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+ SET(PTHREAD_FOUND 0)
+ SET(PTHREAD_LIBRARIES)
+ SET(PTHREAD_INCLUDE_DIR)
+ENDIF(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+
+# Report the results.
+IF(NOT PTHREAD_FOUND)
+ SET(PTHREAD_DIR_MESSAGE
+ "PTHREAD was not found. Make sure PTHREAD_LIBRARY and PTHREAD_INCLUDE_DIR are set. Pthread is required to compile.")
+ IF(PTHREAD_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "${PTHREAD_DIR_MESSAGE}")
+ ELSEIF(NOT PTHREAD_FIND_QUIETLY)
+ MESSAGE(STATUS "${PTHREAD_DIR_MESSAGE}")
+ ENDIF(PTHREAD_FIND_REQUIRED)
+ENDIF(NOT PTHREAD_FOUND)

0 comments on commit e63cd5e

Please sign in to comment.