NiceModules.cmake 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. # clean flags for modules enabled on previous cmake run
  2. # this is necessary to correctly handle modules removal
  3. foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
  4. if(HAVE_${mod})
  5. unset(HAVE_${mod} CACHE)
  6. endif()
  7. unset(OPENCV_MODULE_${mod}_REQ_DEPS CACHE)
  8. unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE)
  9. endforeach()
  10. # clean modules info which needs to be recalculated
  11. set(OPENCV_MODULES_PUBLIC "" CACHE INTERNAL "List of OpenCV modules marked for export")
  12. set(OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules included into the build")
  13. set(OPENCV_MODULES_DISABLED_USER "" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
  14. set(OPENCV_MODULES_DISABLED_AUTO "" CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
  15. set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
  16. # get a list of all sub directories in curdir
  17. MACRO(SUBDIRLIST result curdir)
  18. FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
  19. SET(dirlist "")
  20. FOREACH(child ${children})
  21. IF(IS_DIRECTORY ${curdir}/${child})
  22. SET(dirlist ${dirlist} ${child})
  23. ENDIF()
  24. ENDFOREACH()
  25. SET(${result} ${dirlist})
  26. ENDMACRO()
  27. # collect modules from specified directories
  28. # NB: must be called only once!
  29. macro(ocv_glob_modules modulepath)
  30. if(DEFINED OPENCV_INITIAL_PASS)
  31. message(FATAL_ERROR "OpenCV has already loaded its modules. Calling ocv_glob_modules second time is not allowed.")
  32. endif()
  33. set(__directories_observed "")
  34. #nice-----
  35. #get_filename_component(currDirName ${CMAKE_CURRENT_SOURCE_DIR} NAME )
  36. #get_filename_component(currDirName ${modulepath} NAME )
  37. #set(the_module "${the_module}_${currDirName}")
  38. #message(STATUS "currDirName=${currDirName}")
  39. #------
  40. # collect modules
  41. set(OPENCV_INITIAL_PASS ON)
  42. foreach(__path ${modulepath} ) #${ARGN})
  43. ocv_get_real_path(__path "${__path}")
  44. list(FIND __directories_observed "${__path}" __pathIdx)
  45. if(__pathIdx GREATER -1)
  46. message(FATAL_ERROR "The directory ${__path} is observed for OpenCV modules second time.")
  47. endif()
  48. list(APPEND __directories_observed "${__path}")
  49. file(GLOB __ocvmodules RELATIVE "${__path}" "${__path}/*")
  50. if(__ocvmodules)
  51. list(SORT __ocvmodules)
  52. foreach(mod ${__ocvmodules})
  53. ocv_get_real_path(__modpath "${__path}/${mod}")
  54. if(EXISTS "${__modpath}/CMakeLists.txt")
  55. #message(STATUS "${__modpath} adding subdir")
  56. list(FIND __directories_observed "${__modpath}" __pathIdx)
  57. if(__pathIdx GREATER -1)
  58. message(FATAL_ERROR "The module from ${__modpath} is already loaded.")
  59. endif()
  60. list(APPEND __directories_observed "${__modpath}")
  61. if(OCV_MODULE_RELOCATE_ON_INITIAL_PASS)
  62. #file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
  63. file(COPY "${__modpath}/CMakeLists.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
  64. add_subdirectory("${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
  65. if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
  66. set(OPENCV_MODULE_opencv_${mod}_LOCATION "${__modpath}" CACHE PATH "" FORCE)
  67. endif()
  68. else()
  69. add_subdirectory("${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
  70. endif()
  71. endif()
  72. endforeach()
  73. endif()
  74. endforeach()
  75. ocv_clear_vars(__ocvmodules __directories_observed __path __modpath __pathIdx)
  76. # resolve dependencies
  77. # __ocv_flatten_module_dependencies()
  78. # create modules
  79. set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE)
  80. set(OPENCV_INITIAL_PASS OFF)
  81. foreach(m ${OPENCV_MODULES_BUILD})
  82. message(STATUS "${OPENCV_MODULES_BUILD}")
  83. if(m MATCHES "^opencv_")
  84. string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
  85. add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
  86. endif()
  87. endforeach()
  88. unset(__shortname)
  89. endmacro()
  90. # adds dependencies to OpenCV module
  91. # Usage:
  92. # add_dependencies(opencv_<name> [REQUIRED] [<list of dependencies>] [OPTIONAL <list of modules>])
  93. # Notes:
  94. # * <list of dependencies> - can include full names of modules or full pathes to shared/static libraries or cmake targets
  95. macro(ocv_add_dependencies full_modname)
  96. #we don't clean the dependencies here to allow this macro several times for every module
  97. foreach(d "REQUIRED" ${ARGN})
  98. if(d STREQUAL "REQUIRED")
  99. set(__depsvar OPENCV_MODULE_${full_modname}_REQ_DEPS)
  100. elseif(d STREQUAL "OPTIONAL")
  101. set(__depsvar OPENCV_MODULE_${full_modname}_OPT_DEPS)
  102. else()
  103. list(APPEND ${__depsvar} "${d}")
  104. endif()
  105. endforeach()
  106. unset(__depsvar)
  107. ocv_list_unique(OPENCV_MODULE_${full_modname}_REQ_DEPS)
  108. ocv_list_unique(OPENCV_MODULE_${full_modname}_OPT_DEPS)
  109. set(OPENCV_MODULE_${full_modname}_REQ_DEPS ${OPENCV_MODULE_${full_modname}_REQ_DEPS} CACHE INTERNAL "Required dependencies of ${full_modname} module")
  110. set(OPENCV_MODULE_${full_modname}_OPT_DEPS ${OPENCV_MODULE_${full_modname}_OPT_DEPS} CACHE INTERNAL "Optional dependencies of ${full_modname} module")
  111. endmacro()
  112. # declare new OpenCV module in current folder
  113. # Usage:
  114. # ocv_add_module(<name> [INTERNAL|BINDINGS] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
  115. # Example:
  116. # ocv_add_module(yaom INTERNAL opencv_core opencv_highgui opencv_flann OPTIONAL opencv_gpu)
  117. macro(ocv_add_module _name)
  118. #string(TOLOWER "${_name}" name)
  119. #string(REGEX REPLACE "^opencv_" "" ${name} "${name}")
  120. #set(the_module opencv_${name})
  121. #-----
  122. get_filename_component(currDirName ${CMAKE_CURRENT_SOURCE_DIR} NAME )
  123. set(the_module "${the_module}_${currDirName}")
  124. #----
  125. # the first pass - collect modules info, the second pass - create targets
  126. if(OPENCV_INITIAL_PASS)
  127. #guard agains redefinition
  128. if(";${OPENCV_MODULES_BUILD};${OPENCV_MODULES_DISABLED_USER};" MATCHES ";${the_module};")
  129. message(FATAL_ERROR "Redefinition of the ${the_module} module.
  130. at: ${CMAKE_CURRENT_SOURCE_DIR}
  131. previously defined at: ${OPENCV_MODULE_${the_module}_LOCATION}
  132. ")
  133. endif()
  134. if(NOT DEFINED the_description)
  135. set(the_description "The ${name} OpenCV module")
  136. endif()
  137. if(NOT DEFINED BUILD_${the_module}_INIT)
  138. set(BUILD_${the_module}_INIT ON)
  139. endif()
  140. # create option to enable/disable this module
  141. # option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ${BUILD_${the_module}_INIT})
  142. # remember the module details
  143. set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
  144. set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
  145. # parse list of dependencies
  146. if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS")
  147. set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The cathegory of the module")
  148. set(__ocv_argn__ ${ARGN})
  149. list(REMOVE_AT __ocv_argn__ 0)
  150. ocv_add_dependencies(${the_module} ${__ocv_argn__})
  151. unset(__ocv_argn__)
  152. else()
  153. set(OPENCV_MODULE_${the_module}_CLASS "PUBLIC" CACHE INTERNAL "The cathegory of the module")
  154. ocv_add_dependencies(${the_module} ${ARGN})
  155. if(BUILD_${the_module})
  156. set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} "${the_module}" CACHE INTERNAL "List of OpenCV modules marked for export")
  157. endif()
  158. endif()
  159. # add self to the world dependencies
  160. if(NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS" OR OPENCV_MODULE_IS_PART_OF_WORLD)
  161. ocv_add_dependencies(opencv_world OPTIONAL ${the_module})
  162. endif()
  163. if(BUILD_${the_module})
  164. set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} "${the_module}" CACHE INTERNAL "List of OpenCV modules included into the build")
  165. else()
  166. set(OPENCV_MODULES_DISABLED_USER ${OPENCV_MODULES_DISABLED_USER} "${the_module}" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
  167. endif()
  168. # TODO: add submodules if any
  169. # stop processing of current file
  170. # return()
  171. else(OPENCV_INITIAL_PASS)
  172. if(NOT BUILD_${the_module})
  173. return() # extra protection from redefinition
  174. endif()
  175. project(${the_module})
  176. endif(OPENCV_INITIAL_PASS)
  177. endmacro()
  178. # setup include paths for the list of passed modules
  179. macro(ocv_include_modules)
  180. foreach(d ${ARGN})
  181. if(d MATCHES "^opencv_" AND HAVE_${d})
  182. # message(STATUS "${OPENCV_MODULE_${d}_LOCATION}")
  183. if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
  184. ocv_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
  185. endif()
  186. elseif(EXISTS "${d}")
  187. ocv_include_directories("${d}")
  188. endif()
  189. endforeach()
  190. endmacro()
  191. # setup include path for OpenCV headers for specified module
  192. # ocv_module_include_directories(<extra include directories/extra include modules>)
  193. macro(ocv_module_include_directories)
  194. # ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include"
  195. # "${OPENCV_MODULE_${the_module}_LOCATION}/src"
  196. # "${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
  197. # )
  198. ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/"
  199. "${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
  200. )
  201. ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
  202. endmacro()
  203. # sets header and source files for the current module
  204. # NB: all files specified as headers will be installed
  205. # Usage:
  206. # ocv_set_module_sources([HEADERS] <list of files> [SOURCES] <list of files>)
  207. macro(ocv_set_module_sources)
  208. #opencv: set(OPENCV_MODULE_${the_module}_HEADERS "" )
  209. #opencv: set(OPENCV_MODULE_${the_module}_SOURCES "" )
  210. set(OPENCV_MODULE_${the_module}_HEADERS "" PARENT_SCOPE)
  211. set(OPENCV_MODULE_${the_module}_SOURCES "" PARENT_SCOPE)
  212. foreach(f "HEADERS" ${ARGN})
  213. if(f STREQUAL "HEADERS" OR f STREQUAL "SOURCES")
  214. set(__filesvar "OPENCV_MODULE_${the_module}_${f}")
  215. else()
  216. list(APPEND ${__filesvar} "${f}")
  217. endif()
  218. endforeach()
  219. # the hacky way to embeed any files into the OpenCV without modification of its build system
  220. if(COMMAND ocv_get_module_external_sources)
  221. ocv_get_module_external_sources()
  222. endif()
  223. # use full paths for module to be independent from the module location
  224. ocv_convert_to_full_paths(OPENCV_MODULE_${the_module}_HEADERS)
  225. set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
  226. set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
  227. endmacro()
  228. # finds and sets headers and sources for the standard OpenCV module
  229. # Usage:
  230. # ocv_glob_module_sources(<extra sources&headers in the same format as used in ocv_set_module_sources>)
  231. macro(ocv_glob_module_sources)
  232. # file(GLOB_RECURSE lib_srcs "src/*.cpp")
  233. # file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
  234. # file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
  235. # file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
  236. # source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
  237. # source_group("Include" FILES ${lib_hdrs})
  238. # source_group("Include\\detail" FILES ${lib_hdrs_detail})
  239. # ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail} SOURCES ${lib_srcs} ${lib_int_hdrs})
  240. file(GLOB lib_srcs "*.cpp")
  241. #file(GLOB_RECURSE lib_int_hdrs "./*.hpp" "./*.h")
  242. #file(GLOB_RECURSE lib_int_hdrs "./*.hpp" "./*.h")
  243. file(GLOB lib_hdrs "*.hpp" "*.h" "*.tcc")
  244. #message(status "lib_srcs: ${lib_srcs}")
  245. #message(status "lib_hdrs: ${lib_hdrs}")
  246. source_group("Src" FILES ${lib_srcs})
  247. source_group("Include" FILES ${lib_hdrs})
  248. ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} SOURCES ${lib_srcs})
  249. endmacro()
  250. # creates OpenCV module in current folder
  251. # creates new target, configures standard dependencies, compilers flags, install rules
  252. # Usage:
  253. # ocv_create_module(<extra link dependencies>)
  254. # ocv_create_module(SKIP_LINK)
  255. macro(ocv_create_module)
  256. ##############################################
  257. ### process all subdirs #####
  258. #get list subdirs
  259. # include subdirs if != progs && != test, handle these two separately
  260. set(__path "${CMAKE_CURRENT_SOURCE_DIR}")
  261. #file(GLOB __listSubdirs RELATIVE "${__path}" "${__path}/*")
  262. SUBDIRLIST(__listSubdirs "${__path}")
  263. if(__listSubdirs)
  264. list(SORT __listSubdirs)
  265. foreach(currSubDir ${__listSubdirs})
  266. ocv_get_real_path(__subdirpath "${__path}/${currSubDir}")
  267. #message(STATUS "${currSubDir}")
  268. #message(STATUS "subdir examining: ${__subdirpath}")
  269. if(EXISTS "${__subdirpath}/CMakeLists.txt")
  270. message(STATUS "${currSubDir} has CMakeLists.txt")
  271. if ( "${currSubDir}" STREQUAL "tests" )
  272. if( NICE_BUILD_TESTS )
  273. #add tests
  274. #add_subdirectory("${__subdirpath}")
  275. else()
  276. message(STATUS "by configuration: tests/ not added")
  277. endif()
  278. elseif( "${currSubDir}" STREQUAL "progs" )
  279. if( NICE_BUILD_PROGS )
  280. #add progs
  281. add_subdirectory("${__subdirpath}")
  282. else()
  283. message(STATUS "by configuration: progs/ not added")
  284. endif()
  285. else()
  286. message(STATUS "adding subdir")
  287. add_subdirectory("${__subdirpath}")
  288. #add subdir sources to the accumulated source variable of this directory
  289. #message(STATUS "subdir-sources: ${OPENCV_MODULE_${the_module}_${currSubDir}_SOURCES}")
  290. set(OPENCV_MODULE_${the_module}_SOURCES "${OPENCV_MODULE_${the_module}_SOURCES}" "${OPENCV_MODULE_${the_module}_${currSubDir}_SOURCES}")
  291. set(OPENCV_MODULE_${the_module}_HEADERS "${OPENCV_MODULE_${the_module}_HEADERS}" "${OPENCV_MODULE_${the_module}_${currSubDir}_HEADERS}")
  292. #message(STATUS "accumulated sources of ${the_module}: ${OPENCV_MODULE_${the_module}_SOURCES}")
  293. #message(STATUS "accumulated headers of ${the_module}: ${OPENCV_MODULE_${the_module}_HEADERS}")
  294. endif()
  295. endif()
  296. endforeach()
  297. endif()
  298. ##################################################
  299. #add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
  300. # message(STATUS "linking source files of ${the_module}: ${OPENCV_MODULE_${the_module}_SOURCES}")
  301. # message(STATUS "linking header files of ${the_module}: ${OPENCV_MODULE_${the_module}_HEADERS}")
  302. add_library(${the_module} ${NICE_BUILD_LIBS_STATIC_SHARED} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
  303. if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
  304. target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
  305. endif()
  306. #jojo add_dependencies(opencv_modules ${the_module})
  307. if(ENABLE_SOLUTION_FOLDERS)
  308. set_target_properties(${the_module} PROPERTIES FOLDER "modules")
  309. endif()
  310. set_target_properties(${the_module} PROPERTIES
  311. OUTPUT_NAME "${the_module}${OPENCV_DLLVERSION}"
  312. DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
  313. ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
  314. RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
  315. INSTALL_NAME_DIR lib
  316. )
  317. # For dynamic link numbering convenions
  318. if(NOT ANDROID)
  319. # Android SDK build scripts can include only .so files into final .apk
  320. # As result we should not set version properties for Android
  321. set_target_properties(${the_module} PROPERTIES
  322. VERSION ${OPENCV_VERSION}
  323. SOVERSION ${OPENCV_SOVERSION}
  324. )
  325. endif()
  326. if(BUILD_SHARED_LIBS)
  327. if(MSVC)
  328. set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
  329. else()
  330. add_definitions(-DCVAPI_EXPORTS)
  331. endif()
  332. endif()
  333. if(MSVC)
  334. if(CMAKE_CROSSCOMPILING)
  335. set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
  336. endif()
  337. set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
  338. endif()
  339. install(TARGETS ${the_module}
  340. RUNTIME DESTINATION bin COMPONENT main
  341. LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
  342. ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
  343. )
  344. # only "public" headers need to be installed
  345. if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
  346. foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
  347. string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
  348. if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$")
  349. install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT main)
  350. endif()
  351. endforeach()
  352. endif()
  353. endmacro()
  354. # opencv precompiled headers macro (can add pch to modules and tests)
  355. # this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
  356. # Usage:
  357. # ocv_add_precompiled_headers(${the_module})
  358. macro(ocv_add_precompiled_headers the_target)
  359. if("${the_target}" MATCHES "^opencv_test_.*$")
  360. SET(pch_path "test/test_")
  361. elseif("${the_target}" MATCHES "^opencv_perf_.*$")
  362. SET(pch_path "perf/perf_")
  363. else()
  364. SET(pch_path "src/")
  365. endif()
  366. set(pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp")
  367. if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
  368. if(CMAKE_GENERATOR MATCHES Visual)
  369. set(${the_target}_pch "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.cpp")
  370. add_native_precompiled_header(${the_target} ${pch_header})
  371. elseif(CMAKE_GENERATOR MATCHES Xcode)
  372. add_native_precompiled_header(${the_target} ${pch_header})
  373. elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
  374. add_precompiled_header(${the_target} ${pch_header})
  375. endif()
  376. endif()
  377. unset(pch_header)
  378. unset(pch_path)
  379. unset(${the_target}_pch)
  380. endmacro()