CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ####################################################
  2. ## library individual settings
  3. #library name (name is appended to "nice_" to form the target library name)
  4. set(the_library "core")
  5. #define variable nice_<libname>_HDR and nice_<libname>_SRC for library header and source files (don't include progs and test source files here)
  6. include( corefiles.cmake)
  7. #define variable nice_<libname>_PROGFILES_HDR and nice_<libname>_PROGFILES_SRC for program header and source files (don't include library and test source files here)
  8. include( progfiles.cmake)
  9. #define variable nice_<libname>_TESTFILES_HDR and nice_<libname>_TESTFILES_SRC for unit test header and source files (don't include library and progs source files here)
  10. include( testfiles.cmake)
  11. #add linkage dependencies to other libraries here
  12. set("nice_${the_library}_LINKING_DEPENDENCIES" "")
  13. #####################################################
  14. message(STATUS "adding library ${the_library}")
  15. ADD_LIBRARY("nice_${the_library}" ${NICE_BUILD_LIBS_STATIC_SHARED} ${nice_${the_library}_HDR} ${nice_${the_library}_SRC})
  16. TARGET_LINK_LIBRARIES("nice_${the_library}" "${nice_${the_library}_LINKING_DEPENDENCIES}" ${Boost_LIBRARIES} ${OPENGL_LIBRARY} ${GLUT_LIBRARY} ${QT_LIBRARIES})
  17. SET_PROPERTY(TARGET "nice_${the_library}" PROPERTY FOLDER "library")
  18. INSTALL(TARGETS "nice_${the_library}" DESTINATION lib)
  19. if(BUILD_CORE_PROGS)
  20. message(STATUS "building progs:")
  21. foreach(__progcpp ${nice_${the_library}_PROGFILES_SRC})
  22. get_filename_component(__progname ${__progcpp} NAME_WE )
  23. message(STATUS "progname: ${__progname} ${__progcpp}")
  24. ADD_EXECUTABLE( ${__progname} ${__progcpp})
  25. TARGET_LINK_LIBRARIES(${__progname} "nice_${the_library}")
  26. INSTALL(TARGETS ${__progname} DESTINATION bin)
  27. SET_PROPERTY(TARGET ${__progname} PROPERTY FOLDER "programs")
  28. endforeach()
  29. endif()
  30. if(BUILD_CORE_TESTS)
  31. INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
  32. message(STATUS "building tests:")
  33. foreach(__testcpp ${nice_${the_library}_TESTFILES_SRC})
  34. get_filename_component(__testname ${__testcpp} NAME_WE )
  35. message(STATUS "unittest: ${__testname} ${__testcpp}")
  36. ADD_EXECUTABLE( ${__testname} ../templates/cppUnitTestRunner.cpp ${__testcpp})
  37. TARGET_LINK_LIBRARIES(${__testname} "nice_${the_library}" ${CPPUNIT_LIBRARIES} )
  38. INSTALL(TARGETS ${__testname} DESTINATION tests)
  39. SET_PROPERTY(TARGET ${__testname} PROPERTY FOLDER "unittests")
  40. ADD_TEST(${__testname} ${__testname})
  41. endforeach()
  42. endif()
  43. #####
  44. set(the_module "nice_${the_library}")
  45. if(ENABLE_SOLUTION_FOLDERS)
  46. set_target_properties(${the_module} PROPERTIES FOLDER "modules")
  47. endif()
  48. set_target_properties(${the_module} PROPERTIES
  49. OUTPUT_NAME "${the_module}${OPENCV_DLLVERSION}"
  50. DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
  51. ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
  52. RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
  53. INSTALL_NAME_DIR lib
  54. )
  55. if(BUILD_SHARED_LIBS)
  56. if(MSVC)
  57. set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
  58. else()
  59. add_definitions(-DCVAPI_EXPORTS)
  60. endif()
  61. endif()
  62. if(MSVC)
  63. if(CMAKE_CROSSCOMPILING)
  64. set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
  65. endif()
  66. set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
  67. endif()
  68. install(TARGETS ${the_module}
  69. RUNTIME DESTINATION bin COMPONENT main
  70. LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
  71. ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
  72. )
  73. # # only "public" headers need to be installed
  74. # if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
  75. # foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
  76. # string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
  77. # if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$")
  78. # install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT main)
  79. # endif()
  80. # endforeach()
  81. # endif()