diff --git a/CMakeLists.txt b/CMakeLists.txt index e0fec7b82..1e578dd8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ if(BUILD_POSTGRESQL_CONNECTOR) endif() if(BUILD_WITH_MODULES) - add_subdirectory(module) + add_subdirectory(modules) endif() ### Packaging @@ -112,7 +112,6 @@ write_basic_package_version_file(Sqlpp23ConfigVersion.cmake ARCH_INDEPENDENT ) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Sqlpp23ConfigVersion.cmake DESTINATION ${SQLPP23_INSTALL_CMAKEDIR} ) @@ -151,7 +150,6 @@ if(BUILD_POSTGRESQL_CONNECTOR) install_component(NAME Sqlpp23PostgreSQL TARGETS sqlpp23_postgresql DIRECTORY postgresql) endif() - ### Tests if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests) diff --git a/module/CMakeLists.txt b/modules/CMakeLists.txt similarity index 70% rename from module/CMakeLists.txt rename to modules/CMakeLists.txt index 13f6bf71d..76a30fe34 100644 --- a/module/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -22,6 +22,19 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# The module targets should really be of INTERFACE type, because it is a header-only +# library which doesn't build any library files for them. However CMake disallows +# using the INTERFACE library type if the library has any C++20 modules. For details +# see https://discourse.cmake.org/t/header-only-libraries-and-c-20-modules/10680 +# +# On the other hand using a regular library type for the module libraries means +# that any call to install(TARGET...) for the module targets will fail because it will +# also try to install the non-existent library file. This in turn means that we cannot +# use install(TARGET...) to install the .cmm files and have to resort to +# install(FILES...) + +set(SQLPP23_INSTALL_MODULE_DIR ${CMAKE_INSTALL_PREFIX}/modules/sqlpp23) + # Core library module add_library(sqlpp23.core.module) target_sources(sqlpp23.core.module @@ -30,6 +43,7 @@ target_sources(sqlpp23.core.module sqlpp23.core.cppm ) target_link_libraries(sqlpp23.core.module PUBLIC sqlpp23) +install(FILES sqlpp23.core.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR}) add_library(sqlpp23.mock_db.module) target_sources(sqlpp23.mock_db.module @@ -38,6 +52,7 @@ target_sources(sqlpp23.mock_db.module sqlpp23.mock_db.cppm ) target_link_libraries(sqlpp23.mock_db.module PUBLIC sqlpp23.core.module) +install(FILES sqlpp23.mock_db.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR}) if(BUILD_SQLITE3_CONNECTOR OR BUILD_SQLCIPHER_CONNECTOR) add_library(sqlpp23.sqlite3.module) @@ -47,6 +62,7 @@ if(BUILD_SQLITE3_CONNECTOR OR BUILD_SQLCIPHER_CONNECTOR) sqlpp23.sqlite3.cppm ) target_link_libraries(sqlpp23.sqlite3.module PUBLIC sqlpp23.core.module sqlpp23::sqlite3) + install(FILES sqlpp23.sqlite3.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR}) endif() if(BUILD_MYSQL_CONNECTOR OR BUILD_MARIADB_CONNECTOR) @@ -57,6 +73,7 @@ if(BUILD_MYSQL_CONNECTOR OR BUILD_MARIADB_CONNECTOR) sqlpp23.mysql.cppm ) target_link_libraries(sqlpp23.mysql.module PUBLIC sqlpp23.core.module sqlpp23::mysql) + install(FILES sqlpp23.mysql.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR}) endif() if(BUILD_POSTGRESQL_CONNECTOR) @@ -67,6 +84,5 @@ if(BUILD_POSTGRESQL_CONNECTOR) sqlpp23.postgresql.cppm ) target_link_libraries(sqlpp23.postgresql.module PUBLIC sqlpp23.core.module sqlpp23::postgresql) + install(FILES sqlpp23.postgresql.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR}) endif() - - diff --git a/module/sqlpp23.core.cppm b/modules/sqlpp23.core.cppm similarity index 100% rename from module/sqlpp23.core.cppm rename to modules/sqlpp23.core.cppm diff --git a/module/sqlpp23.mock_db.cppm b/modules/sqlpp23.mock_db.cppm similarity index 100% rename from module/sqlpp23.mock_db.cppm rename to modules/sqlpp23.mock_db.cppm diff --git a/module/sqlpp23.mysql.cppm b/modules/sqlpp23.mysql.cppm similarity index 100% rename from module/sqlpp23.mysql.cppm rename to modules/sqlpp23.mysql.cppm diff --git a/module/sqlpp23.postgresql.cppm b/modules/sqlpp23.postgresql.cppm similarity index 100% rename from module/sqlpp23.postgresql.cppm rename to modules/sqlpp23.postgresql.cppm diff --git a/module/sqlpp23.sqlite3.cppm b/modules/sqlpp23.sqlite3.cppm similarity index 100% rename from module/sqlpp23.sqlite3.cppm rename to modules/sqlpp23.sqlite3.cppm diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index 1b655daf2..7df314596 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -27,7 +27,7 @@ if(BUILD_WITH_MODULES) target_sources(sqlpp23.test.core.tables.module PUBLIC FILE_SET all_my_modules TYPE CXX_MODULES FILES - module/sqlpp23.test.core.tables.cppm + modules/sqlpp23.test.core.tables.cppm ) target_link_libraries(sqlpp23.test.core.tables.module PUBLIC sqlpp23.core.module) endif() diff --git a/tests/core/module/sqlpp23.test.core.tables.cppm b/tests/core/modules/sqlpp23.test.core.tables.cppm similarity index 97% rename from tests/core/module/sqlpp23.test.core.tables.cppm rename to tests/core/modules/sqlpp23.test.core.tables.cppm index 8a990e937..29bd91fba 100644 --- a/tests/core/module/sqlpp23.test.core.tables.cppm +++ b/tests/core/modules/sqlpp23.test.core.tables.cppm @@ -1,7 +1,7 @@ module; // clang-format off -// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/core/tables.sql --path-to-module tests/core/module/sqlpp23.test.core.tables.cppm --module-name=sqlpp23.test.core.tables --namespace test --assume-auto-id +// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/core/tables.sql --path-to-module tests/core/modules/sqlpp23.test.core.tables.cppm --module-name=sqlpp23.test.core.tables --namespace test --assume-auto-id #include diff --git a/tests/mysql/CMakeLists.txt b/tests/mysql/CMakeLists.txt index 6186b9bcb..597db57d2 100644 --- a/tests/mysql/CMakeLists.txt +++ b/tests/mysql/CMakeLists.txt @@ -27,7 +27,7 @@ if(BUILD_WITH_MODULES) target_sources(sqlpp23.test.mysql.tables.module PUBLIC FILE_SET all_my_modules TYPE CXX_MODULES FILES - module/sqlpp23.test.mysql.tables.cppm + modules/sqlpp23.test.mysql.tables.cppm ) target_link_libraries(sqlpp23.test.mysql.tables.module PUBLIC sqlpp23.core.module) endif() diff --git a/tests/mysql/module/sqlpp23.test.mysql.tables.cppm b/tests/mysql/modules/sqlpp23.test.mysql.tables.cppm similarity index 98% rename from tests/mysql/module/sqlpp23.test.mysql.tables.cppm rename to tests/mysql/modules/sqlpp23.test.mysql.tables.cppm index 9b9485ae6..587e1da47 100644 --- a/tests/mysql/module/sqlpp23.test.mysql.tables.cppm +++ b/tests/mysql/modules/sqlpp23.test.mysql.tables.cppm @@ -1,7 +1,7 @@ module; // clang-format off -// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/mysql/tables.sql --path-to-module tests/mysql/module/sqlpp23.test.mysql.tables.cppm --namespace test --assume-auto-id --module-name sqlpp23.test.mysql.tables --generate-table-creation-helper +// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/mysql/tables.sql --path-to-module tests/mysql/modules/sqlpp23.test.mysql.tables.cppm --namespace test --assume-auto-id --module-name sqlpp23.test.mysql.tables --generate-table-creation-helper #include diff --git a/tests/postgresql/CMakeLists.txt b/tests/postgresql/CMakeLists.txt index 1d7955845..85191fb53 100644 --- a/tests/postgresql/CMakeLists.txt +++ b/tests/postgresql/CMakeLists.txt @@ -27,7 +27,7 @@ if(BUILD_WITH_MODULES) target_sources(sqlpp23.test.postgresql.tables.module PUBLIC FILE_SET all_my_modules TYPE CXX_MODULES FILES - module/sqlpp23.test.postgresql.tables.cppm + modules/sqlpp23.test.postgresql.tables.cppm ) target_link_libraries(sqlpp23.test.postgresql.tables.module PUBLIC sqlpp23.core.module) endif() diff --git a/tests/postgresql/module/sqlpp23.test.postgresql.tables.cppm b/tests/postgresql/modules/sqlpp23.test.postgresql.tables.cppm similarity index 98% rename from tests/postgresql/module/sqlpp23.test.postgresql.tables.cppm rename to tests/postgresql/modules/sqlpp23.test.postgresql.tables.cppm index 0d3fb0b18..6c14b4a4d 100644 --- a/tests/postgresql/module/sqlpp23.test.postgresql.tables.cppm +++ b/tests/postgresql/modules/sqlpp23.test.postgresql.tables.cppm @@ -1,7 +1,7 @@ module; // clang-format off -// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/postgresql/tables.sql --path-to-module tests/postgresql/module/sqlpp23.test.postgresql.tables.cppm --namespace test --assume-auto-id --module-name sqlpp23.test.postgresql.tables --generate-table-creation-helper +// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/postgresql/tables.sql --path-to-module tests/postgresql/modules/sqlpp23.test.postgresql.tables.cppm --namespace test --assume-auto-id --module-name sqlpp23.test.postgresql.tables --generate-table-creation-helper #include diff --git a/tests/sqlite3/CMakeLists.txt b/tests/sqlite3/CMakeLists.txt index c09451d39..177c296a9 100644 --- a/tests/sqlite3/CMakeLists.txt +++ b/tests/sqlite3/CMakeLists.txt @@ -27,7 +27,7 @@ if(BUILD_WITH_MODULES) target_sources(sqlpp23.test.sqlite3.tables.module PUBLIC FILE_SET all_my_modules TYPE CXX_MODULES FILES - module/sqlpp23.test.sqlite3.tables.cppm + modules/sqlpp23.test.sqlite3.tables.cppm ) target_link_libraries(sqlpp23.test.sqlite3.tables.module PUBLIC sqlpp23.core.module) endif() diff --git a/tests/sqlite3/module/sqlpp23.test.sqlite3.tables.cppm b/tests/sqlite3/modules/sqlpp23.test.sqlite3.tables.cppm similarity index 97% rename from tests/sqlite3/module/sqlpp23.test.sqlite3.tables.cppm rename to tests/sqlite3/modules/sqlpp23.test.sqlite3.tables.cppm index b1650802f..19931c7a2 100644 --- a/tests/sqlite3/module/sqlpp23.test.sqlite3.tables.cppm +++ b/tests/sqlite3/modules/sqlpp23.test.sqlite3.tables.cppm @@ -1,7 +1,7 @@ module; // clang-format off -// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/sqlite3/tables.sql --path-to-module tests/sqlite3/module/sqlpp23.test.sqlite3.tables.cppm --namespace test --assume-auto-id --module-name sqlpp23.test.sqlite3.tables --generate-table-creation-helper +// generated by ./scripts/sqlpp23-ddl2cpp --path-to-ddl tests/include/sqlpp23/tests/sqlite3/tables.sql --path-to-module tests/sqlite3/modules/sqlpp23.test.sqlite3.tables.cppm --namespace test --assume-auto-id --module-name sqlpp23.test.sqlite3.tables --generate-table-creation-helper #include