From fe3abc6520be8bae70ce48d956de10f2e4ae1d40 Mon Sep 17 00:00:00 2001 From: Sylvain Joubert Date: Thu, 8 Feb 2018 10:32:20 +0100 Subject: [PATCH] Install and export ddl2cpp script --- CMakeLists.txt | 7 ++++++- cmake/Sqlpp11Config.cmake | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56ee04e2..0b15323e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,11 @@ install(TARGETS sqlpp11 EXPORT Sqlpp11Targets ) +install(PROGRAMS "${PROJECT_SOURCE_DIR}/scripts/ddl2cpp" + RENAME sqlpp11-ddl2cpp + DESTINATION bin +) + include(CMakePackageConfigHelpers) write_basic_package_version_file( @@ -113,4 +118,4 @@ if(ENABLE_TESTS) add_subdirectory(test_static_asserts) add_subdirectory(test_constraints) add_subdirectory(test_scripts) -endif() \ No newline at end of file +endif() diff --git a/cmake/Sqlpp11Config.cmake b/cmake/Sqlpp11Config.cmake index 015ab4b6..720fef2d 100644 --- a/cmake/Sqlpp11Config.cmake +++ b/cmake/Sqlpp11Config.cmake @@ -29,3 +29,17 @@ include(CMakeFindDependencyMacro) find_dependency(HinnantDate REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/Sqlpp11Targets.cmake") + +# Import "ddl2cpp" script +if(TARGET sqlpp11::ddl2cpp) + message(FATAL_ERROR "Target sqlpp11::ddl2cpp already defined") +endif() +get_filename_component(sqlpp11_ddl2cpp_location "${CMAKE_CURRENT_LIST_DIR}/../../../bin/sqlpp11-ddl2cpp" REALPATH) +if(NOT EXISTS "${sqlpp11_ddl2cpp_location}") + message(FATAL_ERROR "The imported target sqlpp11::ddl2cpp references the file '${sqlpp11_ddl2cpp_location}' but this file does not exists.") +endif() +add_executable(sqlpp11::ddl2cpp IMPORTED) +set_target_properties(sqlpp11::ddl2cpp PROPERTIES + IMPORTED_LOCATION "${sqlpp11_ddl2cpp_location}" +) +unset(sqlpp11_ddl2cpp_location)