# HG changeset patch # User Andreas Metzler # Date 1299761852 -3600 # Node ID 1838e9b3b365d33f9279d76092c61c32cf536572 # Parent 0950db0798457911aa4aba05ec4045e070cf154e Use locally installed zthread library if available Search for locally installed zthread library. Use it if found, fall back to included copy otherwise. diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,6 +261,8 @@ MESSAGE(STATUS "Program msgfmt found (${MSGFMT_EXECUTABLE})") ENDIF(MSGFMT_FOUND) +FIND_PACKAGE(ZThread) + IF(WIN32) # HTML Helpworkshop for creating help file FIND_PACKAGE(HTMLHelp) diff --git a/CMakeModules/FindZThread.cmake b/CMakeModules/FindZThread.cmake new file mode 100644 --- /dev/null +++ b/CMakeModules/FindZThread.cmake @@ -0,0 +1,25 @@ +# Search for ZThread library +# Copyright (C) 2011 Andreas Metzler. Public Domain + +# Search for locally install zthread library, fall back to copy in +# src/foreign otherwise. +# Sets these variables: +# ZTHREAD_INCLUDE_DIRS +# ZTHREAD_LIBRARIES +# ZTHREAD_FOUND + + +find_path(ZTHREAD_INCLUDE_DIRS zthread/Runnable.h) + +if(ZTHREAD_INCLUDE_DIRS) + find_library(ZTHREAD_LIBRARIES ZThread) + if(ZTHREAD_LIBRARIES) + MESSAGE(STATUS "ZThread library found") + set(ZTHREAD_FOUND "YES") + endif(ZTHREAD_LIBRARIES) +else(ZTHREAD_INCLUDE_DIRS) + message(STATUS "ZThread library not found. falling back to included copy") + set(ZTHREAD_LIBRARIES "ZThread") + set(ZTHREAD_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/src/foreign/zthread/include") +endif(ZTHREAD_INCLUDE_DIRS) + diff --git a/src/foreign/CMakeLists.txt b/src/foreign/CMakeLists.txt --- a/src/foreign/CMakeLists.txt +++ b/src/foreign/CMakeLists.txt @@ -4,7 +4,10 @@ add_subdirectory(levmar) add_subdirectory(lensdb) add_subdirectory(flann) + +IF(NOT ZTHREAD_FOUND) add_subdirectory(zthread/src) +ENDIF(NOT ZTHREAD_FOUND) IF (WIN32 AND NOT MINGW) add_subdirectory(getopt) diff --git a/src/hugin_cpfind/cpfind/CMakeLists.txt b/src/hugin_cpfind/cpfind/CMakeLists.txt --- a/src/hugin_cpfind/cpfind/CMakeLists.txt +++ b/src/hugin_cpfind/cpfind/CMakeLists.txt @@ -3,9 +3,9 @@ ) IF(WIN32) - target_link_libraries(cpfind localfeatures ZThread ${image_libs} ${common_libs} celeste flann_cpp) + target_link_libraries(cpfind localfeatures ${ZTHREAD_LIBRARIES} ${image_libs} ${common_libs} celeste flann_cpp) ELSE(WIN32) - target_link_libraries(cpfind localfeatures ZThread pthread ${image_libs} ${common_libs} celeste flann_cpp) + target_link_libraries(cpfind localfeatures ${ZTHREAD_LIBRARIES} pthread ${image_libs} ${common_libs} celeste flann_cpp) ENDIF(WIN32) install(TARGETS cpfind DESTINATION ${BINDIR}) diff --git a/src/hugin_cpfind/localfeatures/CMakeLists.txt b/src/hugin_cpfind/localfeatures/CMakeLists.txt --- a/src/hugin_cpfind/localfeatures/CMakeLists.txt +++ b/src/hugin_cpfind/localfeatures/CMakeLists.txt @@ -28,9 +28,9 @@ add_executable(keypoints keypoints.cpp) IF(WIN32) - target_link_libraries(keypoints localfeatures ZThread ${image_libs} ${common_libs}) + target_link_libraries(keypoints localfeatures ${ZTHREAD_LIBRARIES} ${image_libs} ${common_libs}) ELSE(WIN32) - target_link_libraries(keypoints localfeatures ZThread pthread ${image_libs} ${common_libs}) + target_link_libraries(keypoints localfeatures ${ZTHREAD_LIBRARIES} pthread ${image_libs} ${common_libs}) ENDIF(WIN32) install(TARGETS keypoints DESTINATION ${BINDIR})