0027344: Configuration, CMake: bugs with detecting third-party products
authorski <ski@opencascade.com>
Tue, 5 Apr 2016 09:38:53 +0000 (12:38 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 2 Jun 2016 11:23:45 +0000 (14:23 +0300)
Information messages for TCL/TK search are corrected.

Compile definitions were added to OpenCASCADEConfig.cmake file

CMakeLists.txt
adm/cmake/tcl.cmake
adm/cmake/tk.cmake
adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in [new file with mode: 0644]
adm/templates/OpenCASCADEConfig.cmake.in

index 3c2a6a0..f51c81a 100644 (file)
@@ -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 $<$<CONFIG:${OCCT_CONFIGURATION}>:${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})
index 2d6e9f0..5e76864 100644 (file)
@@ -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()
index a1e1d94..5f58ae0 100644 (file)
@@ -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 (file)
index 0000000..e08d046
--- /dev/null
@@ -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@
index 8cf9061..46ce0ab 100644 (file)
@@ -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 ()