mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use a separate target to copy files to build folder
Several operations was attached to the POST_BUILD custom command of the ResInsight target. The number of characters in this command exceeded the limit on Windows, and error message "line too long" was displayed on GitHub actions. Suggested solution to copy files into build folder - add new target ResInsightDummyTarget used to find full path to build folder - add new target PreBuildFileCopy for file copy - add all copy operations as a list of cmake commands on PreBuildFileCopy
This commit is contained in:
parent
ea56ceaea0
commit
7fb8de2204
@ -380,15 +380,33 @@ else()
|
|||||||
endforeach(OPENVDS_LIB_NAME)
|
endforeach(OPENVDS_LIB_NAME)
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
# Copy dependencies to make it possible to run ResInsight from the build folder
|
# create an empty library target that will be used to copy files to the build
|
||||||
foreach(FILE_TO_COPY ${RI_FILENAMES})
|
# folder
|
||||||
add_custom_command(
|
add_library(ResInsightDummyTarget EXCLUDE_FROM_ALL empty.cpp)
|
||||||
TARGET ResInsight
|
set_property(TARGET ResInsightDummyTarget PROPERTY FOLDER "FileCopyTargets")
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_TO_COPY}
|
# create a custom target that copies the files to the build folder
|
||||||
$<TARGET_FILE_DIR:ResInsight>
|
foreach(riFileName ${RI_FILENAMES})
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
copyCommands
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_COMMAND}
|
||||||
|
-E
|
||||||
|
copy_if_different
|
||||||
|
${riFileName}
|
||||||
|
$<TARGET_FILE_DIR:ResInsightDummyTarget>
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
add_custom_target(
|
||||||
|
PreBuildFileCopy
|
||||||
|
COMMENT "PreBuildFileCopy step: copy runtime files into build folder"
|
||||||
|
${copyCommands}
|
||||||
|
)
|
||||||
|
set_property(TARGET PreBuildFileCopy PROPERTY FOLDER "FileCopyTargets")
|
||||||
|
|
||||||
|
# Make ResInsight depend on the prebuild target.
|
||||||
|
add_dependencies(ResInsight PreBuildFileCopy)
|
||||||
|
|
||||||
# Generate Python code in a target that is part of ALL_BUILD and depends on
|
# Generate Python code in a target that is part of ALL_BUILD and depends on
|
||||||
# ResInsight
|
# ResInsight
|
||||||
|
10
ApplicationExeCode/empty.cpp
Normal file
10
ApplicationExeCode/empty.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// This empty file is used by ResInsightDummyTarget
|
||||||
|
//
|
||||||
|
// Creating a dummy target with an empty file is used to have a different target than ResInsight.
|
||||||
|
// This target is used to find the full path to the build folder.
|
||||||
|
//
|
||||||
|
// $<TARGET_FILE_DIR:ResInsightDummyTarget>
|
||||||
|
//
|
||||||
|
// If we use the ResInsight target ($<TARGET_FILE_DIR:ResInsight>), we get a circular dependency.
|
||||||
|
//
|
Loading…
Reference in New Issue
Block a user