Skip to content

Commit

Permalink
cmake: use more coherent target names
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Jan 2, 2025
1 parent bf7948f commit 248e85e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,13 @@ list(REMOVE_ITEM ARILES_CORE_DEPENDENCY_INCLUDES "")
if (${ARILES_ENABLE_CORE})
set(ARILES_CORE_BUILD_INCLUDES "${PROJECT_BINARY_DIR}/include/core/")

add_library(${PROJECT_NAME}-core INTERFACE)
target_include_directories(${PROJECT_NAME}-core INTERFACE
add_library(core INTERFACE)
target_include_directories(core INTERFACE
"$<BUILD_INTERFACE:${ARILES_CORE_BUILD_INCLUDES}>"
"$<INSTALL_INTERFACE:include/>"
"$<INSTALL_INTERFACE:${ARILES_CORE_DEPENDENCY_INCLUDES}>"
)
target_compile_features(${PROJECT_NAME}-core INTERFACE "cxx_std_${CMAKE_CXX_STANDARD}")

target_compile_features(core INTERFACE "cxx_std_${CMAKE_CXX_STANDARD}")

# --------------
# build config
Expand Down Expand Up @@ -327,7 +326,7 @@ if (${ARILES_ENABLE_CORE})


set(ariles_LIBRARIES "${PROJECT_NAME}-core_LIBRARIES")
set(ARILES_LIBRARIES "${PROJECT_NAME}-core")
set(ARILES_LIBRARIES "${PROJECT_NAME}::core")

set(ARILES_COMPONENT_CMAKE_DIR "share/${PROJECT_NAME}-core/")

Expand All @@ -351,7 +350,7 @@ if (${ARILES_ENABLE_CORE})


install(
TARGETS ${PROJECT_NAME}-core EXPORT core_targets
TARGETS core EXPORT core_targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT core
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand All @@ -377,6 +376,7 @@ if (${ARILES_ENABLE_CORE})
EXPORT core_targets
DESTINATION ${ARILES_COMPONENT_CMAKE_DIR}
COMPONENT core
NAMESPACE ${PROJECT_NAME}::
)


Expand Down
8 changes: 5 additions & 3 deletions cmake/ariles_install_component.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cpack_add_component(
get_target_property(TARGET_TYPE ${TGT_ARILES_VISITOR_LIB} TYPE)

if(TARGET_TYPE STREQUAL "SHARED_LIBRARY" OR TARGET_TYPE STREQUAL "STATIC_LIBRARY")
target_link_libraries(${TGT_ARILES_VISITOR_LIB} PUBLIC ${PROJECT_NAME}-core)
target_link_libraries(${TGT_ARILES_VISITOR_LIB} PUBLIC core)

target_include_directories(${TGT_ARILES_VISITOR_LIB} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/extra_visitors/${ARILES_VISITOR}/>
Expand All @@ -24,12 +24,13 @@ if(TARGET_TYPE STREQUAL "SHARED_LIBRARY" OR TARGET_TYPE STREQUAL "STATIC_LIBRARY
set_target_properties(${TGT_ARILES_VISITOR_LIB} PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(${TGT_ARILES_VISITOR_LIB} PROPERTIES VISIBILITY_INLINES_HIDDEN YES)
else()
target_link_libraries(${TGT_ARILES_VISITOR_LIB} INTERFACE ${PROJECT_NAME}-core)
target_link_libraries(${TGT_ARILES_VISITOR_LIB} INTERFACE core)

target_include_directories(${TGT_ARILES_VISITOR_LIB} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/extra_visitors/${ARILES_VISITOR}/>
)
endif()
set_target_properties(${TGT_ARILES_VISITOR_LIB} PROPERTIES EXPORT_NAME "${ARILES_VISITOR}")

target_include_directories(${TGT_ARILES_VISITOR_LIB} INTERFACE
"$<INSTALL_INTERFACE:include/>"
Expand All @@ -50,6 +51,7 @@ install(
EXPORT ${ARILES_COMPONENT}_targets
DESTINATION ${ARILES_COMPONENT_CMAKE_DIR}
COMPONENT ${ARILES_COMPONENT}
NAMESPACE ${PROJECT_NAME}::visitor::
)

# BUG? if CMAKE_BUILD_TYPE is not set explicitly, configuration files are not installed
Expand All @@ -66,7 +68,7 @@ add_dependencies(${VISITOR_TARGET_PREFIX}_${ARILES_VISITOR} ${TGT_ARILES_VISITOR


set(ariles_LIBRARIES "${PROJECT_NAME}-${ARILES_COMPONENT}_LIBRARIES")
set(ARILES_LIBRARIES "${TGT_ARILES_VISITOR_LIB}")
set(ARILES_LIBRARIES "${PROJECT_NAME}::visitor::${ARILES_VISITOR}")
set(ARILES_FIND_CORE "find_package(${PROJECT_NAME}-core REQUIRED)")
if(ARILES_VISITOR_${ARILES_VISITOR}_LIBRARY_DIRS)
set(ARILES_LINK_DIRECTORIES "link_directories(\"${ARILES_VISITOR_${ARILES_VISITOR}_LIBRARY_DIRS}\")")
Expand Down

0 comments on commit 248e85e

Please sign in to comment.