Closed smanders closed 1 year ago
also, while looking at the cmake documentation for get_filename_component
https://cmake.org/cmake/help/v3.24/command/get_filename_component.html it appears PATH
is a legacy alias for DIRECTORY
-- so might as well switch some of the externpro cmake (there are still going to be a few patches that use PATH
, for now)
turns out the .rc file has to be built as part of the executable (the .rc is for Windows)... can't be only in a VersionLib that is linked in -- so I'm gonna change things up a bit and call the new cmake function xpVersionLib
and call it with the target as the first argument and do everything else, like actually creating and using the VersionLib, behind the scenes
so now projects will simplify to the following:
diff --git a/vantComm/tool/PntToPntTestTool/CMakeLists.txt b/vantComm/tool/PntToPntTestTool/CMakeLists.txt
index eccea671..ad3d7046 100644
--- a/vantComm/tool/PntToPntTestTool/CMakeLists.txt
+++ b/vantComm/tool/PntToPntTestTool/CMakeLists.txt
@@ -1,11 +1,6 @@
project(PntToPntTestTool VERSION ${CMAKE_PROJECT_VERSION})
set(exe_name ${PROJECT_NAME})
#######################################
-set(PACKAGE_START_YEAR 2022)
-xpGenerateResources(cmake/Vantage.ico CMakeGenerated_srcs)
-source_group(CMakeGenerated FILES ${CMakeGenerated_srcs})
-list(APPEND ${exe_name}_srcs ${CMakeGenerated_srcs})
-#######################################
set(exe_srcs
main.cpp
)
@@ -13,11 +8,8 @@ source_group("" FILES ${exe_srcs})
list(APPEND ${exe_name}_srcs ${exe_srcs})
#######################################
add_executable(${exe_name} ${${exe_name}_srcs})
-target_include_directories(${exe_name} PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR} # for Version.hpp
- ${CommonLibraries_SOURCE_DIR} # for Vantage.ico
- )
target_link_libraries(${exe_name} PRIVATE Boost::program_options Revision vantComm)
+xpVersionLib(${exe_name} ICON ${CommonLibraries_SOURCE_DIR}/cmake/Vantage.ico START_YEAR 2022)
set_property(TARGET ${exe_name} PROPERTY FOLDER ${folder})
install(TARGETS ${exe_name} DESTINATION bintool COMPONENT tool)
xpSourceListAppend("${${exe_name}_srcs}")
completed with commits to dev branch referenced above verified with TemplateMicroservice (on Linux and Windows) and other projects that generate resources in various ways
currently
xpGenerateResources()
generates resource files: Version.hpp, resource.rc, resource.h https://github.com/smanders/externpro/blob/23.02/modules/xpfunmac.cmake#L1476-L1507it also populates a list of these generated sources which are manually added to the source list so they are searchable and part of the project so they are able to be brought up in an IDE (Visual Studio)
but the worst part of this is that the executable using these resources needs access to the icon file and the directory where the generated resources are, and this is typically CommonLibs_SOURCE_DIR (for the Vantage.ico) and CMAKE_CURRENT_BINARY_DIR (for Version.hpp)
I've reviewed some code that abuses the access to these directories -- so it's time to lock things down: generate these resources in a
VersionLib/
directory and only give access to that directory, and create a${exe_name}Version
INTERFACE library that gives access toVersionLib/
and the icon directory -- this INTERFACE library can also add the generated source, so would no longer need to be manually added to the source listthis should simplify projects requiring VersionLib
also, an upcoming release of cmakeify, which will standardize and clean-up our
target_include_directories()
calls will be fine to ditch the# for Version.hpp
and# for Vantage.io
comments