Skip to content

Commit

Permalink
Add option to configure header subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
offa committed Oct 22, 2024
1 parent 2588071 commit 1e21c83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ option(INFLUXCXX_WITH_BOOST "Build with Boost support enabled" ON)
option(INFLUXCXX_TESTING "Enable testing for this component" ON)
option(INFLUXCXX_SYSTEMTEST "Enable system tests" ON)
option(INFLUXCXX_COVERAGE "Enable Coverage" OFF)
option(INFLUXCXX_INSTALL_HEADER_TO_SUBDIR "Install header to InfluxDB/ subdir - will be default in 0.8.0" OFF)

# Define project
project(influxdb-cxx
Expand Down Expand Up @@ -69,6 +70,11 @@ message(STATUS "Boost support : ${INFLUXCXX_WITH_BOOST}")
message(STATUS "Unit Tests : ${INFLUXCXX_TESTING}")
message(STATUS "System Tests : ${INFLUXCXX_SYSTEMTEST}")

set(HEADER_INSTALL_PATH "include")

if (INFLUXCXX_INSTALL_HEADER_TO_SUBDIR)
set(HEADER_INSTALL_PATH "InfluxDB/include")
endif()

# Add coverage flags
if(INFLUXCXX_COVERAGE)
Expand Down Expand Up @@ -149,8 +155,8 @@ write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/cmake/InfluxDBConf
)

# Install headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/InfluxDB")
install(FILES ${PROJECT_BINARY_DIR}/src/influxdb_export.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/InfluxDB")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_INSTALL_PATH}")
install(FILES ${PROJECT_BINARY_DIR}/src/influxdb_export.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_INSTALL_PATH}")

# Export targets
install(EXPORT InfluxDBTargets
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ generate_export_header(InfluxDB)

target_include_directories(InfluxDB
PUBLIC
$<INSTALL_INTERFACE:include/InfluxDB>
$<INSTALL_INTERFACE:${HEADER_INSTALL_PATH}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
# for export header
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>
Expand Down

0 comments on commit 1e21c83

Please sign in to comment.