diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c2a6a0d23..f51c81a56b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -804,6 +804,8 @@ endif() set (OCCT_MODULES_ENABLED) set (OCCT_LIBRARIES) set (SET_OpenCASCADE_MODULES_TOOLKITS "\n# List of available OpenCASCADE libraries for each module\n") +set (OCCT_COMPILE_DEFINITIONS) + foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS}) if (TARGET ${OCCT_TOOLKIT}) @@ -816,10 +818,33 @@ foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS}) get_target_property (${OCCT_TOOLKIT}_MODULE ${OCCT_TOOLKIT} "MODULE") list (APPEND OCCT_MODULES_ENABLED ${${OCCT_TOOLKIT}_MODULE}) list (APPEND OpenCASCADE_${${OCCT_TOOLKIT}_MODULE}_TOOLKITS ${OCCT_TOOLKIT}) + + # get compile definitions of target directory + get_directory_property (COMPILE_DEFINITIONS DIRECTORY "${${OCCT_TOOLKIT}_SOURCE_DIR}" "COMPILE_DEFINITIONS") + list (APPEND OCCT_COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS}) endif() endif() endforeach() list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED) +list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS) + +# export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files +foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES}) + set (SET_OpenCASCADE_COMPILE_DEFINITIONS) + string (TOUPPER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_UPPER) + string (TOLOWER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_LOWER) + foreach(COMPILE_DEFINITION ${OCCT_COMPILE_DEFINITIONS}) + string(REPLACE "(" "\\(" COMPILE_DEFINITION "${COMPILE_DEFINITION}") + string(REPLACE ")" "\\)" COMPILE_DEFINITION "${COMPILE_DEFINITION}") + set (SET_OpenCASCADE_COMPILE_DEFINITIONS "${SET_OpenCASCADE_COMPILE_DEFINITIONS}set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:${COMPILE_DEFINITION}>)\n") + endforeach() + set (SET_OpenCASCADE_CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${OCCT_CONFIGURATION_UPPER}}") + set (SET_OpenCASCADE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${OCCT_CONFIGURATION_UPPER}}") + configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in" "OpenCASCADECompileDefinitionsAndFlags-${OCCT_CONFIGURATION_LOWER}.cmake" @ONLY) +endforeach() +# install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration +install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)") +install (CODE "configure_file(\"${CMAKE_BINARY_DIR}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" COPYONLY)") foreach (OCCT_MODULE ${OCCT_MODULES}) if (BUILD_MODULE_${OCCT_MODULE}) diff --git a/adm/cmake/tcl.cmake b/adm/cmake/tcl.cmake index 2d6e9f02fb..5e7686470b 100644 --- a/adm/cmake/tcl.cmake +++ b/adm/cmake/tcl.cmake @@ -55,7 +55,7 @@ endif() COMPLIANCE_PRODUCT_CONSISTENCY(TCL) # use default (CMake) TCL search -find_package(TCL) +find_package(TCL QUIET) # tcl include dir if (NOT 3RDPARTY_TCL_INCLUDE_DIR) @@ -291,4 +291,4 @@ if (NOT BUILD_SHARED_LIBS) OCCT_CHECK_AND_UNSET (3RDPARTY_TCL_DLL) OCCT_CHECK_AND_UNSET (3RDPARTY_TCL_DLL_DIR) OCCT_CHECK_AND_UNSET (INSTALL_TCL) -endif() \ No newline at end of file +endif() diff --git a/adm/cmake/tk.cmake b/adm/cmake/tk.cmake index a1e1d94686..5f58ae07bf 100644 --- a/adm/cmake/tk.cmake +++ b/adm/cmake/tk.cmake @@ -59,7 +59,7 @@ endif() COMPLIANCE_PRODUCT_CONSISTENCY(TK) # use default (CMake) TCL search -find_package(TCL) +find_package(TCL QUIET) # tk include dir if (NOT 3RDPARTY_TK_INCLUDE_DIR) @@ -283,4 +283,4 @@ if (NOT BUILD_SHARED_LIBS) OCCT_CHECK_AND_UNSET (3RDPARTY_TK_DLL) OCCT_CHECK_AND_UNSET (3RDPARTY_TK_DLL_DIR) OCCT_CHECK_AND_UNSET (INSTALL_TK) -endif() \ No newline at end of file +endif() diff --git a/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in b/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in new file mode 100644 index 0000000000..e08d046f22 --- /dev/null +++ b/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in @@ -0,0 +1,14 @@ +#----------------------------------------------------------------------------- +# +# OpenCASCADECompileDefinitionsAndFlags-@OCCT_CONFIGURATION_LOWER@.cmake - OpenCASCADE CMake file +# with compile definitions and C/C++ flags for @OCCT_CONFIGURATION@ configuration. +# +# This file is configured by OpenCASCADE. +# + +# The C and C++ flags added by OpenCASCADE to the cmake-configured flags. +set (OpenCASCADE_C_FLAGS_@OCCT_CONFIGURATION_UPPER@ "@SET_OpenCASCADE_CMAKE_C_FLAGS@") +set (OpenCASCADE_CXX_FLAGS_@OCCT_CONFIGURATION_UPPER@ "@SET_OpenCASCADE_CMAKE_CXX_FLAGS@") + +# The compile definitions used by OpenCASCADE. +@SET_OpenCASCADE_COMPILE_DEFINITIONS@ diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in index 8cf9061d2c..46ce0ab510 100644 --- a/adm/templates/OpenCASCADEConfig.cmake.in +++ b/adm/templates/OpenCASCADEConfig.cmake.in @@ -54,7 +54,7 @@ set (OpenCASCADE_BUILD_WITH_DEBUG @BUILD_WITH_DEBUG@) set (OpenCASCADE_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) @SET_OpenCASCADE_BUILD_TYPE@ -# Use of third-party libraries +# Use of third-party libraries. set (OpenCASCADE_WITH_TCL @USE_TCL@) set (OpenCASCADE_WITH_FREETYPE @USE_FREETYPE@) set (OpenCASCADE_WITH_FREEIMAGE @USE_FREEIMAGE@) @@ -64,6 +64,12 @@ set (OpenCASCADE_WITH_VTK @USE_VTK@) @SET_OpenCASCADE_WITH_D3D@ @SET_OpenCASCADE_WITH_GLX@ +# Import OpenCASCADE compile definitions, C and C++ flags for each installed configuration. +file(GLOB CONFIG_FILES "${CMAKE_CURRENT_LIST_DIR}/OpenCASCADECompileDefinitionsAndFlags-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + if (NOT OpenCASCADE_FIND_COMPONENTS) set (OpenCASCADE_FIND_COMPONENTS ${OpenCASCADE_MODULES}) endif ()