2222# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2323# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
25+ # The module targets should really be of INTERFACE type, because it is a header-only
26+ # library which doesn't build any library files for them. However CMake disallows
27+ # using the INTERFACE library type if the library has any C++20 modules. For details
28+ # see https://discourse.cmake.org/t/header-only-libraries-and-c-20-modules/10680
29+ #
30+ # On the other hand using a regular library type for the module libraries means
31+ # that any call to install(TARGET...) for the module targets will fail because it will
32+ # also try to install the non-existent library file. This in turn means that we cannot
33+ # use install(TARGET...) to install the .cmm files and have to resort to
34+ # install(FILES...)
35+
36+ set (SQLPP23_INSTALL_MODULE_DIR ${CMAKE_INSTALL_PREFIX} /modules/sqlpp23)
37+
2538# Core library module
2639add_library (sqlpp23.core.module )
2740target_sources (sqlpp23.core.module
@@ -30,6 +43,7 @@ target_sources(sqlpp23.core.module
3043 sqlpp23.core.cppm
3144)
3245target_link_libraries (sqlpp23.core.module PUBLIC sqlpp23 )
46+ install (FILES sqlpp23.core.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR} )
3347
3448add_library (sqlpp23.mock_db.module )
3549target_sources (sqlpp23.mock_db.module
@@ -38,6 +52,7 @@ target_sources(sqlpp23.mock_db.module
3852 sqlpp23.mock_db.cppm
3953)
4054target_link_libraries (sqlpp23.mock_db.module PUBLIC sqlpp23.core.module )
55+ install (FILES sqlpp23.mock_db.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR} )
4156
4257if (BUILD_SQLITE3_CONNECTOR OR BUILD_SQLCIPHER_CONNECTOR)
4358 add_library (sqlpp23.sqlite3.module )
@@ -47,6 +62,7 @@ if(BUILD_SQLITE3_CONNECTOR OR BUILD_SQLCIPHER_CONNECTOR)
4762 sqlpp23.sqlite3.cppm
4863 )
4964 target_link_libraries (sqlpp23.sqlite3.module PUBLIC sqlpp23.core.module sqlpp23::sqlite3 )
65+ install (FILES sqlpp23.sqlite3.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR} )
5066endif ()
5167
5268if (BUILD_MYSQL_CONNECTOR OR BUILD_MARIADB_CONNECTOR)
@@ -57,6 +73,7 @@ if(BUILD_MYSQL_CONNECTOR OR BUILD_MARIADB_CONNECTOR)
5773 sqlpp23.mysql.cppm
5874 )
5975 target_link_libraries (sqlpp23.mysql.module PUBLIC sqlpp23.core.module sqlpp23::mysql )
76+ install (FILES sqlpp23.mysql.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR} )
6077endif ()
6178
6279if (BUILD_POSTGRESQL_CONNECTOR)
@@ -67,6 +84,5 @@ if(BUILD_POSTGRESQL_CONNECTOR)
6784 sqlpp23.postgresql.cppm
6885 )
6986 target_link_libraries (sqlpp23.postgresql.module PUBLIC sqlpp23.core.module sqlpp23::postgresql )
87+ install (FILES sqlpp23.postgresql.cppm DESTINATION ${SQLPP23_INSTALL_MODULE_DIR} )
7088endif ()
71-
72-
0 commit comments