Skip to content

Commit

Permalink
corrosion_install: Add guard and use CMAKE_CURRENT_BINARY_DIR
Browse files Browse the repository at this point in the history
It seems something has been switched up and it's using CMAKE_BINARY_DIR
instead of CMAKE_CURRENT_BINARY_DIR.

Additionally, without a guard CMake will write the static/shared
definitions on every reconfigure, making the config file fail.
  • Loading branch information
Gtker authored and jschwe committed Sep 3, 2024
1 parent bfb9060 commit ebdc500
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1308,16 +1308,20 @@ function(corrosion_install)

if(EXPORT_NAME)
get_target_property(COR_FILE_NAME ${INSTALL_TARGET}-static COR_FILE_NAME)
file(APPEND
${CMAKE_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}-static-exists)
file(APPEND
${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}
"
add_library(${INSTALL_TARGET}-static STATIC IMPORTED)
set_target_properties(${INSTALL_TARGET}-static
PROPERTIES
IMPORTED_LOCATION \"\${PACKAGE_PREFIX_DIR}/${DESTINATION}/${COR_FILE_NAME}\"
)
"
)
)

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}-static-exists)
endif()
endif()
endif()

Expand Down Expand Up @@ -1357,28 +1361,32 @@ set_target_properties(${INSTALL_TARGET}-static
)

if(EXPORT_NAME)
get_target_property(COR_FILE_NAME ${INSTALL_TARGET}-shared COR_FILE_NAME)
file(APPEND
${CMAKE_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}-shared-exists)
get_target_property(COR_FILE_NAME ${INSTALL_TARGET}-shared COR_FILE_NAME)
file(APPEND
${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}
"
add_library(${INSTALL_TARGET}-shared SHARED IMPORTED)
set_target_properties(${INSTALL_TARGET}-shared
PROPERTIES
IMPORTED_LOCATION \"\${PACKAGE_PREFIX_DIR}/${DESTINATION}/${COR_FILE_NAME}\"
)
"
)
)

get_target_property(COR_IMPLIB_FILE_NAME ${INSTALL_TARGET}-shared COR_IMPLIB_FILE_NAME)
if (NOT COR_IMPLIB_FILE_NAME MATCHES .*-NOTFOUND)
file(APPEND
${CMAKE_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}
get_target_property(COR_IMPLIB_FILE_NAME ${INSTALL_TARGET}-shared COR_IMPLIB_FILE_NAME)
if (NOT COR_IMPLIB_FILE_NAME MATCHES .*-NOTFOUND)
file(APPEND
${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}
"
set_target_properties(${INSTALL_TARGET}-shared
PROPERTIES
IMPORTED_IMPLIB \"\${PACKAGE_PREFIX_DIR}/${DESTINATION}/${COR_IMPLIB_FILE_NAME}\"
)"
)
)
endif()

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/corrosion/${EXTRA_TARGETS_EXPORT_NAME}-shared-exists)
endif()
endif()
endif()
Expand Down

0 comments on commit ebdc500

Please sign in to comment.