diff --git a/cmake/Sqlpp11Config.cmake b/cmake/Sqlpp11Config.cmake index 720fef2d..18ea9b1b 100644 --- a/cmake/Sqlpp11Config.cmake +++ b/cmake/Sqlpp11Config.cmake @@ -31,15 +31,14 @@ 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") +if(NOT TARGET sqlpp11::ddl2cpp) + 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) 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)