Skip to content

Commit

Permalink
Rework install paths
Browse files Browse the repository at this point in the history
The install paths can now be configured by setting the corresponding
SOCI_INSTALL_* variables.

Additionally, this commit fixes the header files being installed under
.../soci/soci/bla.h (two "soci" subdirs) and now install properly under
.../soci/bla.h
  • Loading branch information
Krzmbrzl committed Sep 1, 2024
1 parent f4e01a4 commit 8d14ee4
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 40 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Note: we need >= v3.23 in order to make use of file sets for header installation
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down Expand Up @@ -103,10 +104,7 @@ set(SOCI_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}" CACHE STRING "Specifies suffix f


include(soci_compiler_options)

include(GNUInstallDirs)

set(SOCI_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/soci-${PROJECT_VERSION}")
include(soci_install_dirs)

add_subdirectory(src)

Expand Down
15 changes: 15 additions & 0 deletions cmake/soci_install_dirs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(GNUInstallDirs)

set(SOCI_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/soci-${PROJECT_VERSION}"
CACHE FILEPATH "Directory into which cmake related files (e.g. SOCIConfig.cmake) are installed")

set(SOCI_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}"
CACHE FILEPATH "Directory into which to install any SOCI executables")

set(SOCI_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/soci"
CACHE FILEPATH "Directory into which any SOCI libraries (except DLLs on Windows) are installed")

# Note that our headers are installed via a file set that already has the headers
# in a dedicated "soci" subdirectory (which will be part of the installation)
set(SOCI_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}"
CACHE FILEPATH "Directory into which the 'soci' directory with all SOCI header files is installed")
8 changes: 4 additions & 4 deletions src/backends/db2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::DB2)
install(
TARGETS soci_db2
EXPORT SOCIDB2Targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/empty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::Empty)
install(
TARGETS soci_empty
EXPORT SOCIEmptyTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/firebird/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::Firebird)
install(
TARGETS soci_firebird
EXPORT SOCIFirebirdTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/mysql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::MySQL)
install(
TARGETS soci_mysql
EXPORT SOCIMySQLTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::ODBC)
install(
TARGETS soci_odbc
EXPORT SOCIODBCTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/oracle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::Oracle)
install(
TARGETS soci_oracle
EXPORT SOCIOracleTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/postgresql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::PostgreSQL)
install(
TARGETS soci_postgresql
EXPORT SOCIPostgreSQLTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/backends/sqlite3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ target_link_libraries(soci_interface INTERFACE SOCI::SQLite3)
install(
TARGETS soci_sqlite3
EXPORT SOCISQLite3Targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down
8 changes: 4 additions & 4 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ endif()
install(
TARGETS soci_core
EXPORT SOCICoreTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/soci"
RUNTIME DESTINATION "${SOCI_INSTALL_BINDIR}"
COMPONENT soci_runtime
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
LIBRARY DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_runtime
NAMELINK_COMPONENT soci_development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/soci"
ARCHIVE DESTINATION "${SOCI_INSTALL_LIBDIR}"
COMPONENT soci_development
FILE_SET headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soci"
FILE_SET headers DESTINATION "${SOCI_INSTALL_INCLUDEDIR}"
COMPONENT soci_development
)
# Generate and install a targets file
Expand Down

0 comments on commit 8d14ee4

Please sign in to comment.