On Monday 01 of June 2020 10:05:23 Slávek Banko wrote:
On Monday 01 of June 2020 09:40:06 deloptes wrote:
Slávek Banko wrote:
file( GLOB _generated_headers
${CMAKE_CURRENT_BINARY_DIR}/*.h )
install(
FILES ${_generated_headers}
DESTINATION ${INCLUDE_INSTALL_DIR}/<app>/
)
It looks indeed much better, but it did not work :(. It did not
install anything. I have to check what is file(GLOB ....)
oh, sure, I didn't realize - the file( GLOB ... ) is processed during
the configuration, when the header files are not yet present - that's
why it can't work this way. I'll think again...
Cheers
Well, although it's not as nice as the previous recommendations, it seems
to work as needed. Keep in mind that it is necessary to place it after
all add_subdirectory(...) of the appropriate folder to exclude any
possible subfolders.
file( GLOB _bin_dirs RELATIVE ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/* )
unset( _exclude_dirs )
foreach( _dir IN LISTS _bin_dirs )
if( IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir} )
list( APPEND _exclude_dirs PATTERN ${_dir} EXCLUDE )
endif()
endforeach()
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION ${INCLUDE_INSTALL_DIR}/<generated>
FILES_MATCHING PATTERN PATTERN "*.h"
${_exclude_dirs}
)
Note: You will notice a slash after the folder name listed for DIRECTORY -
this is to install only the files in this folder, not the folder itself.
Cheers
--
Slávek