Skip to content

Commit

Permalink
cmake scripts are updated to prefer includes from the OpenCV source tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kamaev committed Mar 3, 2012
1 parent aeaae8b commit 18dbe6b
Show file tree
Hide file tree
Showing 29 changed files with 175 additions and 182 deletions.
3 changes: 0 additions & 3 deletions 3rdparty/CMakeLists.txt

This file was deleted.

26 changes: 0 additions & 26 deletions 3rdparty/ffmpeg/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion 3rdparty/libjasper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(${JASPER_LIBRARY})
add_definitions(-DEXCLUDE_MIF_SUPPORT -DEXCLUDE_PNM_SUPPORT -DEXCLUDE_BMP_SUPPORT -DEXCLUDE_RAS_SUPPORT -DEXCLUDE_JPG_SUPPORT -DEXCLUDE_PGX_SUPPORT)

# List of C++ files:
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
ocv_include_directories(${CMAKE_CURRENT_SOURCE_DIR})

# The .cpp files:
file(GLOB lib_srcs *.c)
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/libjpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(${JPEG_LIBRARY})

# List of C++ files:

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
ocv_include_directories(${CMAKE_CURRENT_SOURCE_DIR})

# The .cpp files:
file(GLOB lib_srcs *.c)
Expand Down
3 changes: 1 addition & 2 deletions 3rdparty/libpng/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ project(${PNG_LIBRARY})

# List of C++ files:

include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(${ZLIB_INCLUDE_DIR})
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIR})

file(GLOB lib_srcs *.c)
file(GLOB lib_hdrs *.h)
Expand Down
4 changes: 1 addition & 3 deletions 3rdparty/libtiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmakein"
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h" @ONLY)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIR})

# List of C++ files:
set(lib_srcs
Expand Down Expand Up @@ -101,8 +101,6 @@ if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()

include_directories(${ZLIB_INCLUDE_DIR})

add_library(${TIFF_LIBRARY} STATIC ${lib_srcs})
target_link_libraries(${TIFF_LIBRARY} ${ZLIB_LIBRARIES})

Expand Down
8 changes: 4 additions & 4 deletions 3rdparty/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ endif()

set(TBB_INCLUDE_DIRS "${tbb_src_dir}/include" PARENT_SCOPE)

include_directories("${tbb_src_dir}/include"
"${tbb_src_dir}/src/"
"${tbb_src_dir}/src/rml/include"
"${CMAKE_CURRENT_SOURCE_DIR}")
ocv_include_directories("${tbb_src_dir}/include"
"${tbb_src_dir}/src/"
"${tbb_src_dir}/src/rml/include"
"${CMAKE_CURRENT_SOURCE_DIR}")

file(GLOB lib_srcs "${tbb_src_dir}/src/tbb/*.cpp")
file(GLOB lib_hdrs "${tbb_src_dir}/src/tbb/*.h")
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ endif()

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein"
"${CMAKE_CURRENT_BINARY_DIR}/zconf.h" @ONLY)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")

set(ZLIB_PUBLIC_HDRS
"${CMAKE_CURRENT_BINARY_DIR}/zconf.h"
Expand Down
13 changes: 5 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ endif()
# ----------------------------------------------------------------------------
set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
add_definitions(-DHAVE_CVCONFIG_H)
include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})


# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -331,7 +331,7 @@ if(UNIX)
if(OPENGL_FOUND)
set(HAVE_OPENGL 1)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
include_directories(${OPENGL_INCLUDE_DIR})
ocv_include_directories(${OPENGL_INCLUDE_DIR})
endif()
endif()
endif()
Expand Down Expand Up @@ -502,7 +502,7 @@ endif()

if(IPP_FOUND)
add_definitions(-DHAVE_IPP)
include_directories(${IPP_INCLUDE_DIRS})
ocv_include_directories(${IPP_INCLUDE_DIRS})
link_directories(${IPP_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_LIBRARIES})
endif()
Expand Down Expand Up @@ -538,7 +538,7 @@ if(WITH_EIGEN)
"/usr/local/include/eigen3" "/opt/include/eigen3" "/usr/include/eigen3"
DOC "The path to Eigen2/Eigen3 headers")
if(EIGEN_INCLUDE_PATH)
include_directories(${EIGEN_INCLUDE_PATH})
ocv_include_directories(${EIGEN_INCLUDE_PATH})
set(HAVE_EIGEN 1)
endif()
endif()
Expand Down Expand Up @@ -569,7 +569,7 @@ if(WIN32)
if(OPENGL_FOUND)
set(HAVE_OPENGL 1)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
include_directories(${OPENGL_INCLUDE_DIR})
ocv_include_directories(${OPENGL_INCLUDE_DIR})
endif()
endif()
endif()
Expand Down Expand Up @@ -603,9 +603,6 @@ add_subdirectory(doc)
# various data that is used by cv libraries and/or demo applications.
add_subdirectory(data)

# 3rdparty libraries on-board
add_subdirectory(3rdparty)

# extra applications
add_subdirectory(apps)

Expand Down
2 changes: 1 addition & 1 deletion apps/haartraining/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()

project(haartraining)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules(${OPENCV_HAARTRAINING_DEPS})

if(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion apps/traincascade/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()

project(traincascade)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules(${OPENCV_TRAINCASCADE_DEPS})

set(traincascade_files traincascade.cpp
Expand Down
7 changes: 4 additions & 3 deletions cmake/OpenCVDetectAndroidSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ find_host_program(ANDROID_EXECUTABLE
NAMES android.bat android
PATHS "${ANDROID_SDK_ENV_PATH}/tools/"
"${ProgramFiles_ENV_PATH}/Android/android-sdk/tools/"
"/opt/android-sdk/tools/"
"${ProgramFiles_ENV_PATH}/Android/android-sdk-windows/tools/"
"/opt/android-sdk-linux/tools/"
"/opt/android-sdk-linux_x86/tools/"
"/opt/android-sdk-linux_86/tools/"
"/opt/android-sdk-linux/tools/"
"/opt/android-sdk-mac/tools/"
"/opt/android-sdk-mac_x86/tools/"
"/opt/android-sdk-mac_86/tools/"
"/opt/android-sdk-mac/tools/"
"/opt/android-sdk/tools/"
"$ENV{HOME}/NVPACK/android-sdk-linux_x86/tools/"
"$ENV{HOME}/NVPACK/android-sdk-linux_86/tools/"
"$ENV{HOME}/NVPACK/android-sdk-linux/tools/"
Expand Down
9 changes: 6 additions & 3 deletions cmake/OpenCVDetectPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ if(PYTHON_EXECUTABLE)
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.")
endif()
elseif(CMAKE_HOST_WIN32)
get_filename_component(PYTHON_PATH "${PYTHON_EXECUTABLE}" PATH CACHE)
get_filename_component(PYTHON_PATH "${PYTHON_EXECUTABLE}" PATH)
file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
if(NOT EXISTS "${PYTHON_PATH}/Lib/site-packages")
unset(PYTHON_PATH)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
endif()
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
endif()
Expand All @@ -46,7 +48,8 @@ if(PYTHON_EXECUTABLE)
if(PYTHON_NUMPY_PROCESS EQUAL 0)
set(PYTHON_USE_NUMPY 1)
add_definitions(-DPYTHON_USE_NUMPY=1)
include_directories(AFTER ${PYTHON_NUMPY_INCLUDE_DIRS})
file(TO_CMAKE_PATH "${PYTHON_NUMPY_INCLUDE_DIRS}" PYTHON_NUMPY_INCLUDE_DIRS)
ocv_include_directories(${PYTHON_NUMPY_INCLUDE_DIRS})
message(STATUS " Use NumPy headers from: ${PYTHON_NUMPY_INCLUDE_DIRS}")
endif()
endif()
Expand Down
6 changes: 3 additions & 3 deletions cmake/OpenCVDetectTBB.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if(ANDROID)
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/tbb")
include_directories(${TBB_INCLUDE_DIRS})
ocv_include_directories(${TBB_INCLUDE_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
add_definitions(-DTBB_USE_GCC_BUILTINS=1 -D__TBB_GCC_BUILTIN_ATOMICS_PRESENT=1 -D__TBB_USE_GENERIC_DWORD_LOAD_STORE=1)
set(HAVE_TBB 1)
Expand All @@ -10,7 +10,7 @@ elseif(UNIX AND NOT APPLE)
if(TBB_FOUND)
set(HAVE_TBB 1)
if(NOT ${TBB_INCLUDE_DIRS} STREQUAL "")
include_directories(${TBB_INCLUDE_DIRS})
ocv_include_directories(${TBB_INCLUDE_DIRS})
endif()
link_directories(${TBB_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${TBB_LIBRARIES})
Expand Down Expand Up @@ -63,7 +63,7 @@ if(NOT HAVE_TBB)

set(HAVE_TBB 1)
if(NOT "${TBB_INCLUDE_DIR}" STREQUAL "")
include_directories("${TBB_INCLUDE_DIR}")
ocv_include_directories("${TBB_INCLUDE_DIR}")
endif()
endif(TBB_INCLUDE_DIR)
endif(NOT HAVE_TBB)
33 changes: 24 additions & 9 deletions cmake/OpenCVExtraTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ CONFIGURE_FILE(
IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(uninstall PROPERTIES FOLDER "CMakeTargets")
endif()


# ----------------------------------------------------------------------------
# Source package, for "make package_source"
Expand All @@ -30,12 +33,15 @@ if(BUILD_PACKAGE)
COMMAND zip -9 -r ${CMAKE_CURRENT_BINARY_DIR}/${TARBALL_NAME}.zip . -x '*/.svn/*' '*.vcproj' '*.pyc'
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(package_source PROPERTIES FOLDER "extra")
endif()
endif()


#-----------------------------------
# ----------------------------------------------------------------------------
# performance tests, for "make perf"
#-----------------------------------
# ----------------------------------------------------------------------------
if(BUILD_PERF_TESTS AND PYTHON_EXECUTABLE)
if(CMAKE_VERSION VERSION_GREATER "2.8.2")
add_custom_target(perf
Expand All @@ -51,23 +57,32 @@ if(BUILD_PERF_TESTS AND PYTHON_EXECUTABLE)
)
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(perf PROPERTIES FOLDER "tests performance")
set_target_properties(perf PROPERTIES FOLDER "extra")
endif()
endif()

#-----------------------------------

# ----------------------------------------------------------------------------
# spefial targets to build all OpenCV modules
# ----------------------------------------------------------------------------
add_custom_target(opencv_modules)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_modules PROPERTIES FOLDER "extra")
endif()


# ----------------------------------------------------------------------------
# spefial targets to build all tests
#-----------------------------------
# ----------------------------------------------------------------------------
if(BUILD_TESTS)
add_custom_target(opencv_tests)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_tests PROPERTIES FOLDER "tests accuracy")
set_target_properties(opencv_tests PROPERTIES FOLDER "extra")
endif()
endif()
if(BUILD_PERF_TESTS)
add_custom_target(opencv_perf_tests)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_perf_tests PROPERTIES FOLDER "tests performance")
set_target_properties(opencv_perf_tests PROPERTIES FOLDER "extra")
endif()
endif()

13 changes: 7 additions & 6 deletions cmake/OpenCVModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,21 @@ macro(ocv_include_modules)
foreach(d ${ARGN})
if(d MATCHES "^opencv_" AND HAVE_${d})
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
ocv_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
endif()
elseif(EXISTS "${d}")
include_directories("${d}")
ocv_include_directories("${d}")
endif()
endforeach()
endmacro()

# setup include path for OpenCV headers for specified module
# ocv_module_include_directories(<extra include directories/extra include modules>)
macro(ocv_module_include_directories)
include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include"
"${OPENCV_MODULE_${the_module}_LOCATION}/src"
"${CMAKE_CURRENT_BINARY_DIR}"#for precompiled headers
)
ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include"
"${OPENCV_MODULE_${the_module}_LOCATION}/src"
"${CMAKE_CURRENT_BINARY_DIR}"#for precompiled headers
)
ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
endmacro()

Expand Down Expand Up @@ -378,6 +378,7 @@ endmacro()
macro(ocv_create_module)
add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
add_dependencies(opencv_modules ${the_module})

if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_module} PROPERTIES FOLDER "modules")
Expand Down
14 changes: 14 additions & 0 deletions cmake/OpenCVUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ if(NOT COMMAND find_host_program)
endmacro()
endif()

#added include directories in such way that directories from the OpenCV source tree go first
macro(ocv_include_directories)
set(__add_before "")
foreach(dir ${ARGN})
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
list(APPEND __add_before "${dir}")
else()
include_directories(AFTER "${dir}")
endif()
endforeach()
include_directories(BEFORE ${__add_before})
endmacro()


# Provides an option that the user can optionally select.
# Can accept condition to control when option is available for user.
Expand Down
4 changes: 2 additions & 2 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ file(GLOB HAAR_CASCADES haarcascades/*.xml)
file(GLOB LBP_CASCADES lbpcascades/*.xml)

if(NOT WIN32)
install(FILES ${HAAR_CASCADES} DESTINATION share/OpenCV/haarcascades COMPONENT main)
install(FILES ${LBP_CASCADES} DESTINATION share/OpenCV/lbpcascades COMPONENT main)
install(FILES ${HAAR_CASCADES} DESTINATION share/OpenCV/haarcascades COMPONENT main)
install(FILES ${LBP_CASCADES} DESTINATION share/OpenCV/lbpcascades COMPONENT main)
endif()
Loading

0 comments on commit 18dbe6b

Please sign in to comment.