浏览代码

CMakelists commit

Johannes R 12 年之前
父节点
当前提交
53991c3c7e

+ 13 - 2
CMakeLists.txt

@@ -39,8 +39,19 @@ INCLUDE_DIRECTORIES(core)
 
 set(the_module "libnice")
 
-ADD_SUBDIRECTORY(core bin)
-
+set(NICE_CURR_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+SUBDIRLIST(__listSubDirs "${NICE_CURR_DIR}")
+foreach(_curSubdir ${__listSubDirs})
+	ocv_get_real_path(__modpath "${NICE_CURR_DIR}/${_curSubdir}/")
+	if(EXISTS "${__modpath}/CMakeLists.txt")
+		message(STATUS "add module: ${__modpath}")
+		#set(__modpath "${__modpath}/")
+		#message(STATUS "add module: ${__modpath}")
+		ocv_glob_modules( ${__modpath} )
+	endif()
+endforeach()
+#ADD_SUBDIRECTORY(core bin)
+  
 # doxygen support
 FIND_PROGRAM(DOXYGEN_EXECUTABLE "doxygen")
 

+ 98 - 12
cmake/NiceModules.cmake

@@ -16,25 +16,36 @@ set(OPENCV_MODULES_DISABLED_AUTO  "" CACHE INTERNAL "List of OpenCV modules impl
 set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
 
 
-
-
+# get a list of all sub directories in curdir
+MACRO(SUBDIRLIST result curdir)
+  FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
+  SET(dirlist "")
+  FOREACH(child ${children})
+    IF(IS_DIRECTORY ${curdir}/${child})
+        SET(dirlist ${dirlist} ${child})
+    ENDIF()
+  ENDFOREACH()
+  SET(${result} ${dirlist})
+ENDMACRO()
 
 # collect modules from specified directories
 # NB: must be called only once!
-macro(ocv_glob_modules)
+macro(ocv_glob_modules modulepath)
   if(DEFINED OPENCV_INITIAL_PASS)
     message(FATAL_ERROR "OpenCV has already loaded its modules. Calling ocv_glob_modules second time is not allowed.")
   endif()
   set(__directories_observed "")
 
   #nice-----
-  get_filename_component(currDirName ${CMAKE_CURRENT_SOURCE_DIR} NAME )
+  #get_filename_component(currDirName ${CMAKE_CURRENT_SOURCE_DIR} NAME )
+  get_filename_component(currDirName ${modulepath} NAME )
   set(the_module "${the_module}_${currDirName}")
+  message(STATUS "currDirName=${currDirName}")
   #------
   
   # collect modules
   set(OPENCV_INITIAL_PASS ON)
-  foreach(__path ${ARGN})
+  foreach(__path ${modulepath} ) #${ARGN})
     ocv_get_real_path(__path "${__path}")
 
     list(FIND __directories_observed "${__path}" __pathIdx)
@@ -48,10 +59,8 @@ macro(ocv_glob_modules)
       list(SORT __ocvmodules)
       foreach(mod ${__ocvmodules})
         ocv_get_real_path(__modpath "${__path}/${mod}")
-		message(STATUS "${mod}")
-		message(STATUS "${__modpath}")
         if(EXISTS "${__modpath}/CMakeLists.txt")
-	  message(STATUS "${__modpath} adding subdir")
+	      message(STATUS "${__modpath} adding subdir")
           list(FIND __directories_observed "${__modpath}" __pathIdx)
           if(__pathIdx GREATER -1)
             message(FATAL_ERROR "The module from ${__modpath} is already loaded.")
@@ -228,8 +237,10 @@ endmacro()
 # Usage:
 # ocv_set_module_sources([HEADERS] <list of files> [SOURCES] <list of files>)
 macro(ocv_set_module_sources)
-  set(OPENCV_MODULE_${the_module}_HEADERS "")
-  set(OPENCV_MODULE_${the_module}_SOURCES "")
+  #opencv: set(OPENCV_MODULE_${the_module}_HEADERS "" )
+  #opencv: set(OPENCV_MODULE_${the_module}_SOURCES "" )
+  set(OPENCV_MODULE_${the_module}_HEADERS "" PARENT_SCOPE)
+  set(OPENCV_MODULE_${the_module}_SOURCES "" PARENT_SCOPE)
 
   foreach(f "HEADERS" ${ARGN})
     if(f STREQUAL "HEADERS" OR f STREQUAL "SOURCES")
@@ -266,10 +277,10 @@ macro(ocv_glob_module_sources)
 
 #  ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail} SOURCES ${lib_srcs} ${lib_int_hdrs})
 
-  file(GLOB lib_srcs "*.cpp" "*.tcc")
+  file(GLOB lib_srcs "*.cpp")
   #file(GLOB_RECURSE lib_int_hdrs "./*.hpp" "./*.h")
   #file(GLOB_RECURSE lib_int_hdrs "./*.hpp" "./*.h")
-  file(GLOB lib_hdrs "*.hpp" "*.h")
+  file(GLOB lib_hdrs "*.hpp" "*.h" "*.tcc")
   message(status "lib_srcs: ${lib_srcs}")
   message(status "lib_hdrs: ${lib_hdrs}")
   source_group("Src" FILES ${lib_srcs})
@@ -283,7 +294,52 @@ endmacro()
 #   ocv_create_module(<extra link dependencies>)
 #   ocv_create_module(SKIP_LINK)
 macro(ocv_create_module)
+	##############################################
+	### process all subdirs #####
+	#get list subdirs
+	# include subdirs if != progs && != test, handle these two separately
+	set(__path "${CMAKE_CURRENT_SOURCE_DIR}")
+	#file(GLOB __listSubdirs RELATIVE "${__path}" "${__path}/*")
+    SUBDIRLIST(__listSubdirs "${__path}")
+	if(__listSubdirs)
+		list(SORT __listSubdirs)
+		foreach(currSubDir ${__listSubdirs})
+			ocv_get_real_path(__subdirpath "${__path}/${currSubDir}")
+			#message(STATUS "${currSubDir}")
+			message(STATUS "subdir examining: ${__subdirpath}")
+			if(EXISTS "${__subdirpath}/CMakeLists.txt")
+				message(STATUS "has CMakeLists.txt")
+				if ( "${currSubDir}" STREQUAL "tests" )
+					if( NICE_BUILD_TESTS )
+						#add tests
+					else()
+						message(STATUS "by configuration: tests/ not added")
+					endif()
+				elseif( "${currSubDir}" STREQUAL "progs" )
+					if( NICE_BUILD_PROGS )
+						#add progs
+					else()
+						message(STATUS "by configuration: progs/ not added")	
+					endif()
+				else()
+					message(STATUS "adding subdir")
+					add_subdirectory("${__subdirpath}")
+					#add subdir sources to the accumulated source variable of this directory
+					message(STATUS "subdir-sources: ${OPENCV_MODULE_${the_module}_${currSubDir}_SOURCES}")
+					set(OPENCV_MODULE_${the_module}_SOURCES "${OPENCV_MODULE_${the_module}_SOURCES}" "${OPENCV_MODULE_${the_module}_${currSubDir}_SOURCES}")
+					set(OPENCV_MODULE_${the_module}_HEADERS "${OPENCV_MODULE_${the_module}_HEADERS}" "${OPENCV_MODULE_${the_module}_${currSubDir}_HEADERS}")
+					message(STATUS "accumulated sources of ${the_module}: ${OPENCV_MODULE_${the_module}_SOURCES}")
+					message(STATUS "accumulated headers of ${the_module}: ${OPENCV_MODULE_${the_module}_HEADERS}")
+				endif()
+			endif()
+		endforeach()
+	endif()
+
+	##################################################
+
   #add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
+  message(STATUS "linking source files of ${the_module}: ${OPENCV_MODULE_${the_module}_SOURCES}")
+  message(STATUS "linking header files of ${the_module}: ${OPENCV_MODULE_${the_module}_HEADERS}")
   add_library(${the_module} ${NICE_BUILD_LIBS_STATIC_SHARED} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})  
 
   if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
@@ -344,4 +400,34 @@ macro(ocv_create_module)
       endif()
     endforeach()
   endif()
+endmacro()
+
+
+# opencv precompiled headers macro (can add pch to modules and tests)
+# this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
+# Usage:
+# ocv_add_precompiled_headers(${the_module})
+macro(ocv_add_precompiled_headers the_target)
+    if("${the_target}" MATCHES "^opencv_test_.*$")
+        SET(pch_path "test/test_")
+    elseif("${the_target}" MATCHES "^opencv_perf_.*$")
+        SET(pch_path "perf/perf_")
+    else()
+        SET(pch_path "src/")
+    endif()
+    set(pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp")
+
+    if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
+        if(CMAKE_GENERATOR MATCHES Visual)
+            set(${the_target}_pch "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.cpp")
+            add_native_precompiled_header(${the_target} ${pch_header})
+        elseif(CMAKE_GENERATOR MATCHES Xcode)
+            add_native_precompiled_header(${the_target} ${pch_header})
+        elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
+            add_precompiled_header(${the_target} ${pch_header})
+        endif()
+    endif()
+    unset(pch_header)
+    unset(pch_path)
+    unset(${the_target}_pch)
 endmacro()

+ 13 - 40
core/CMakeLists.txt

@@ -1,19 +1,21 @@
-set(NICE_CURR_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
-message(STATUS "${NICE_CURR_DIR}")
-get_filename_component(currDirName ${NICE_CURR_DIR} NAME )
-message(status "CMAKE_CURRENT_LIST_DIR : ${currDirName}")
-set(testvar "${testvar}core_")
-message(STATUS "before: ${testvar}")
 
-ocv_glob_modules(${NICE_CURR_DIR})
-message(STATUS "after: ${testvar}")
+# set(NICE_CURR_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+# ocv_glob_modules(${NICE_CURR_DIR})
+ocv_add_module(core)
+
+ocv_module_include_directories()
+ocv_glob_module_sources()
+ocv_create_module()
+
+
+# set(NICE_CURR_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+# ocv_glob_modules(${NICE_CURR_DIR})
 
-####
 ADD_EXECUTABLE(testConfig ./basics/progs/testConfig.cpp)
-ADD_EXECUTABLE(testMemoryUsage ./basics/progs/testMemoryUsage.cpp) 
+ADD_EXECUTABLE(testMemoryUsage ./basics/progs/testMemoryUsage.cpp)
 
 TARGET_LINK_LIBRARIES(testConfig libnice_core_basics libnice_core_vector)
-TARGET_LINK_LIBRARIES(testMemoryUsage libnice_core_basics libnice_core_vector)
+TARGET_LINK_LIBRARIES(testMemoryUsage libnice_core_basics)
 
 INSTALL(TARGETS testConfig DESTINATION bin)
 INSTALL(TARGETS testMemoryUsage DESTINATION bin)
@@ -26,32 +28,3 @@ INSTALL(TARGETS testMemoryUsage DESTINATION bin)
 #  "${PROJECT_BINARY_DIR}/CMakeDefinesConfig.h"
 #)
 #include_directories("${PROJECT_BINARY_DIR}")
-
-#INCLUDE_DIRECTORIES(basics)
-#INCLUDE_DIRECTORIES(algebra)
-#INCLUDE_DIRECTORIES(vector)
-#INCLUDE_DIRECTORIES(optimization)
-#INCLUDE_DIRECTORIES(image)
-
-#INCLUDE_DIRECTORIES(iceconversion)
-#INCLUDE_DIRECTORIES(imagedisplay)
-#INCLUDE_DIRECTORIES(matlabAccess)
-#INCLUDE_DIRECTORIES(progs)
-
-#ADD_SUBDIRECTORY(basics)
-#ADD_SUBDIRECTORY(algebra)
-#ADD_SUBDIRECTORY(vector)
-#ADD_SUBDIRECTORY(optimization)
-#ADD_SUBDIRECTORY(image)
-
-#SET(core_src 
-#${core_basics_src} 
-#${core_algebra_src}
-#${core_vector_src}
-#${core_optimization}
-#${core_image}
-#)
-
-#MESSAGE(STATUS "${core_src}")
-
-#ADD_LIBRARY(core ${NICE_BUILD_LIBS_STATIC_SHARED} ${core_src})

+ 5 - 5
core/basics/CMakeLists.txt

@@ -1,12 +1,12 @@
-message(STATUS "vector_location: ${OPENCV_MODULE_opencv_vector_LOCATION}")
+#message(STATUS "vector_location: ${OPENCV_MODULE_opencv_vector_LOCATION}")
 
 ocv_add_module(basics)# INTERNAL libnice_core_vector)
 
-message(STATUS "vector_location: ${OPENCV_MODULE_vector_LOCATION}")
+#message(STATUS "vector_location: ${OPENCV_MODULE_vector_LOCATION}")
 
 ocv_module_include_directories()
-message(STATUS "vec-sources: ${OPENCV_MODULE_libnice_core_vector_SOURCES}")
-ocv_glob_module_sources(SOURCES ${OPENCV_MODULE_libnice_core_vector_SOURCES})
+#message(STATUS "vec-sources: ${OPENCV_MODULE_libnice_core_vector_SOURCES}")
+ocv_glob_module_sources()#(SOURCES ${OPENCV_MODULE_libnice_core_vector_SOURCES})
 ocv_create_module()
 
-add_subdirectory(progs bin)
+#add_subdirectory(progs bin)

+ 5 - 0
core/matlabAccess/CMakeLists.txt

@@ -0,0 +1,5 @@
+ocv_add_module(matlabAccess)
+
+ocv_module_include_directories()
+ocv_glob_module_sources()
+ocv_create_module()

+ 11 - 0
core/optimization/CMakeLists.txt

@@ -0,0 +1,11 @@
+#get_filename_component(currDirName ${CMAKE_CURRENT_SOURCE_DIR} NAME )
+#set(the_module "${the_module}_${currDirName}")
+
+#add_subdirectory(blackbox)
+#add_subdirectory(gradientBased)
+
+ocv_add_module(optimization)
+
+ocv_module_include_directories()
+ocv_glob_module_sources()
+ocv_create_module()

+ 4 - 12
core/optimization/blackbox/CMakeLists.txt

@@ -1,13 +1,5 @@
-SET(core_optimization_blackbox_src CostFunction.cpp
-DimWrapperCostFunction.cpp
-DownhillSimplexOptimizer.cpp
-Optimizable.cpp
-Optimizer.cpp
-OptLogBase.cpp
-SimpleOptimizer.cpp
-SimpleOptProblem.cpp
-)
+ocv_add_module(blackbox)
 
-ADD_LIBRARY(core_optimization_blackbox ${NICE_BUILD_LIBS_STATIC_SHARED} ${core_optimization_blackbox_src})
-
-INSTALL(TARGETS core_optimization_blackbox DESTINATION libs)
+ocv_module_include_directories()
+ocv_glob_module_sources()
+ocv_create_module()

+ 4 - 12
core/optimization/gradientBased/CMakeLists.txt

@@ -1,13 +1,5 @@
-set(core_optimization_gradientBased_src FirstOrderRasmussen.cpp
-FirstOrderTrustRegion.cpp
-OptimizationAlgorithmFirst.cpp
-OptimizationAlgorithmSecond.cpp
-OptimizationProblemFirst.cpp
-OptimizationProblemSecond.cpp
-SecondOrderTrustRegion.cpp
-TrustRegionBase.cpp
-)
+ocv_add_module(gradientBased)
 
-ADD_LIBRARY(core_optimization_gradientBased ${NICE_BUILD_LIBS_STATIC_SHARED} ${core_optimization_gradientBased_src})
-
-INSTALL(TARGETS core_optimization_gradientBased DESTINATION libs)
+ocv_module_include_directories()
+ocv_glob_module_sources()
+ocv_create_module()

+ 3 - 10
core/vector/CMakeLists.txt

@@ -1,14 +1,7 @@
-message(STATUS "vector_location: ${OPENCV_MODULE_opencv_vector_LOCATION}")
-
 ocv_add_module(vector)
 
-
-set(testvar "${testvar}vector")
-message(STATUS "before: ${testvar}")
-
-
-message(STATUS "vector_location: ${OPENCV_MODULE_vector_LOCATION}")
-
 ocv_module_include_directories()
 ocv_glob_module_sources()
-ocv_create_module()
+ocv_create_module()
+
+#add_subdirectory(progs bin)

+ 12 - 1
readme.txt

@@ -1,4 +1,11 @@
-notes on porting NICE to WIN using CMAKE:
+notes on porting NICE to WIN using CMAKE:
+-------
+fixing all these includes of template definitons:
+//#ifdef __GNUC__
+#include "core/vector/RowMatrixT.tcc"
+//#endif
+tcc are not cpps, they need to be included into the header file otherwise template usage will result in linking errors
+See, Inclusion model of Template classes: http://stackoverflow.com/questions/3705740/c-lnk2019-error-unresolved-external-symbol-template-classs-constructor-and
 
 
 ------------------------------------------
@@ -62,4 +69,8 @@ ocv_glob_modules(pathcurrdir) -->in modules
 defs to care about
 NICE_USELIB_CUDACHOLESKY
 NICE_USELIB_IPP
+#ifdef NICE_USELIB_MATIO
 
+#eigene definiton zum builden der sub-test-ordners
+NICE_BUILD_TESTS	
+NICE_BUILD_PROGS