ソースを参照

CMake: Copy missing files to build dir to allow usage of -Dopen62541_DIR

Stefan Profanter 5 年 前
コミット
fcbbf7db7a
共有4 個のファイルを変更した20 個の追加17 個の削除を含む
  1. 11 12
      CMakeLists.txt
  2. 4 0
      examples/CMakeLists.txt
  3. 3 3
      examples/nodeset/CMakeLists.txt
  4. 2 2
      tools/cmake/open62541Config.cmake.in

+ 11 - 12
CMakeLists.txt

@@ -1096,8 +1096,6 @@ include(linting_target)
 # Enable shared library with `-DBUILD_SHARED_LIBS=ON`
 
 set(cmake_configfile_install ${LIB_INSTALL_DIR}/cmake/open62541)
-set(target_install_dest_name "${cmake_configfile_install}/open62541Targets.cmake")
-set(macros_install_dest_name "${cmake_configfile_install}/open62541Macros.cmake")
 set(open62541_install_tools_dir share/open62541/tools)
 set(open62541_install_nodeset_dir share/open62541/tools/ua-nodeset)
 
@@ -1166,9 +1164,7 @@ include(CMakePackageConfigHelpers)
 configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/open62541Config.cmake.in"
                               "${CMAKE_CURRENT_BINARY_DIR}/open62541Config.cmake"
                               INSTALL_DESTINATION "${cmake_configfile_install}"
-                              PATH_VARS target_install_dest_name
-                                        macros_install_dest_name
-                                        open62541_install_tools_dir
+                              PATH_VARS open62541_install_tools_dir
                                         open62541_install_nodeset_dir
                                         open62541_enabled_components
                               )
@@ -1185,15 +1181,18 @@ install(EXPORT open62541Targets
         DESTINATION "${cmake_configfile_install}"
         NAMESPACE open62541::)
 
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/open62541Config.cmake"
-              "${CMAKE_CURRENT_BINARY_DIR}/open62541ConfigVersion.cmake"
-        DESTINATION "${cmake_configfile_install}")
+export(
+    TARGETS open62541
+    NAMESPACE open62541::
+    FILE ${CMAKE_CURRENT_BINARY_DIR}/open62541Targets.cmake
+)
 
-install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/macros_public.cmake"
-        DESTINATION "${cmake_configfile_install}"
-        RENAME "open62541Macros.cmake"
-        )
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/macros_public.cmake" "${CMAKE_CURRENT_BINARY_DIR}/open62541Macros.cmake" COPYONLY)
 
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/open62541Config.cmake"
+              "${CMAKE_CURRENT_BINARY_DIR}/open62541ConfigVersion.cmake"
+              "${CMAKE_CURRENT_BINARY_DIR}/open62541Macros.cmake"
+        DESTINATION "${cmake_configfile_install}")
 
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     install(FILES "${PROJECT_BINARY_DIR}/src_generated/open62541.pc"

+ 4 - 0
examples/CMakeLists.txt

@@ -26,6 +26,10 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
         set(UA_TOOLS_DIR ${open62541_TOOLS_DIR})
     endif()
 
+    if(NOT UA_NODESET_DIR)
+        set(UA_NODESET_DIR ${open62541_NODESET_DIR})
+    endif()
+
     function(assign_source_group)
         # define empty function. We don't need it in standalone
     endfunction(assign_source_group)

+ 3 - 3
examples/nodeset/CMakeLists.txt

@@ -68,10 +68,10 @@ if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
     set(FILE_BSD_POWERLINK_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
     set(FILE_NS_DIRPREFIX ${CMAKE_SOURCE_DIR}/deps/ua-nodeset)
 else()
-    set(FILE_CSV_DIRPREFIX ${UA_TOOLS_DIR}/ua-nodeset)
-    set(FILE_BSD_PLCOPEN_DIRPREFIX ${UA_TOOLS_DIR}/ua-nodeset)
+    set(FILE_CSV_DIRPREFIX ${UA_NODESET_DIR})
+    set(FILE_BSD_PLCOPEN_DIRPREFIX ${UA_NODESET_DIR})
     set(FILE_BSD_POWERLINK_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
-    set(FILE_NS_DIRPREFIX ${UA_TOOLS_DIR}/ua-nodeset)
+    set(FILE_NS_DIRPREFIX ${UA_NODESET_DIR})
 endif()
 
 # PLCopen requires the full ns0 as basis

+ 2 - 2
tools/cmake/open62541Config.cmake.in

@@ -1,6 +1,6 @@
 @PACKAGE_INIT@
 
-include ("@PACKAGE_target_install_dest_name@")
+include("${CMAKE_CURRENT_LIST_DIR}/open62541Targets.cmake")
 
 set (open62541_TOOLS_DIR @PACKAGE_open62541_install_tools_dir@ CACHE PATH "Path to the directory that contains the tooling of the stack")
 set (open62541_NODESET_DIR @PACKAGE_open62541_install_nodeset_dir@ CACHE PATH "Path to the directory that contains the OPC UA schema repository")
@@ -8,7 +8,7 @@ set (open62541_NODESET_DIR @PACKAGE_open62541_install_nodeset_dir@ CACHE PATH "P
 include(CMakeFindDependencyMacro)
 find_dependency(PythonInterp REQUIRED)
 
-include("@PACKAGE_macros_install_dest_name@")
+include("${CMAKE_CURRENT_LIST_DIR}/open62541Macros.cmake")
 
 set(open62541_COMPONENTS_ALL @open62541_enabled_components@)