From 710f5e8b8910cfdf85cfdf393497be28fdee5a1c Mon Sep 17 00:00:00 2001 From: dkfsoft Date: Fri, 19 Jun 2015 00:05:09 +0500 Subject: [PATCH 1/8] Prepare variable for find module on windows --- CMakeLists.txt | 14 +++++++++++++- cmake/Modules/FindODB.cmake | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86222f8..f96ddaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,21 @@ cmake_minimum_required(VERSION 2.8.12) project(OdbCMake) +# windows section - generate paths based on ODB_ROOT +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + if(DEFINED ENV{ODB_ROOT}) + set(ODB_ROOT $ENV{ODB_ROOT}) + endif(DEFINED ENV{ODB_ROOT}) + message(STATUS "Prepare variables using ODB_ROOT=${ODB_ROOT}") + set(PC_LIBODB_INCLUDE_DIRS "${ODB_ROOT}\\include") + set(PC_LIBODB_LIBRARY_DIRS "${ODB_ROOT}\\lib") + set(ODB_LIBODB_INCLUDE_DIRS "${ODB_ROOT}\\include") + set(ODB_LIBRARY_PATH "${ODB_ROOT}\\lib") +endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") -find_package(ODB REQUIRED COMPONENTS qt sqlite OPTIONAL_COMPONENTS mysql pgsql) +find_package(ODB REQUIRED COMPONENTS sqlite OPTIONAL_COMPONENTS mysql pgsql) include(${ODB_USE_FILE}) set(OdbCMake_SOURCES diff --git a/cmake/Modules/FindODB.cmake b/cmake/Modules/FindODB.cmake index be00506..e10c102 100644 --- a/cmake/Modules/FindODB.cmake +++ b/cmake/Modules/FindODB.cmake @@ -69,7 +69,7 @@ endfunction() pkg_check_modules(PC_LIBODB QUIET "libodb") -set(ODB_LIBRARY_PATH "" CACHE STRING "Common library search hint for all ODB libs") +#set(ODB_LIBRARY_PATH "" CACHE STRING "Common library search hint for all ODB libs") find_path(libodb_INCLUDE_DIR NAMES odb/version.hxx From b9a2164e12910b87c4fcc9ce06f138eafe40fc6f Mon Sep 17 00:00:00 2001 From: a-pavlov Date: Fri, 19 Jun 2015 15:53:35 +0500 Subject: [PATCH 2/8] Add ability to compile all sources into one file --- CMakeLists.txt | 7 ++-- cmake/Modules/UseODB.cmake | 84 +++++++++++++++++++++++++------------- employee.h | 32 +++++++++++++++ 3 files changed, 92 insertions(+), 31 deletions(-) create mode 100644 employee.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f96ddaf..2b1b640 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") -find_package(ODB REQUIRED COMPONENTS sqlite OPTIONAL_COMPONENTS mysql pgsql) +find_package(ODB REQUIRED COMPONENTS mysql OPTIONAL_COMPONENTS pgsql) include(${ODB_USE_FILE}) set(OdbCMake_SOURCES @@ -24,9 +24,10 @@ set(OdbCMake_SOURCES database.h) set(OdbCMake_ODB_HEADERS - person.h) + person.h + employee.h) -odb_compile(OdbCMake_SOURCES FILES ${OdbCMake_ODB_HEADERS} DB sqlite GENERATE_QUERY GENERATE_SESSION) +odb_compile(OdbCMake_SOURCES FILES ${OdbCMake_ODB_HEADERS} DB mysql GENERATE_QUERY GENERATE_SESSION INPUT_NAME "personal") add_executable(odbcmake ${OdbCMake_SOURCES} diff --git a/cmake/Modules/UseODB.cmake b/cmake/Modules/UseODB.cmake index 7aeb3b8..760ef3a 100644 --- a/cmake/Modules/UseODB.cmake +++ b/cmake/Modules/UseODB.cmake @@ -19,7 +19,8 @@ function(odb_compile outvar) HEADER_PROLOGUE INLINE_PROLOGUE SOURCE_PROLOGUE HEADER_EPILOGUE INLINE_EPILOGUE SOURCE_EPILOGUE MULTI_DATABASE - PROFILE) + PROFILE + INPUT_NAME) set(multiValueParams FILES INCLUDE DB) cmake_parse_arguments(PARAM "${options}" "${oneValueParams}" "${multiValueParams}" ${ARGN}) @@ -107,6 +108,11 @@ function(odb_compile outvar) list(APPEND ODB_ARGS --profile "${PARAM_PROFILE}") endif() + if(PARAM_INPUT_NAME) + list(APPEND ODB_ARGS --at-once) + list(APPEND ODB_ARGS --input-name "${PARAM_INPUT_NAME}") + endif() + list(APPEND ODB_ARGS --output-dir "${ODB_COMPILE_OUTPUT_DIR}") list(APPEND ODB_ARGS --hxx-suffix "${ODB_COMPILE_HEADER_SUFFIX}") list(APPEND ODB_ARGS --ixx-suffix "${ODB_COMPILE_INLINE_SUFFIX}") @@ -135,33 +141,55 @@ function(odb_compile outvar) file(REMOVE_RECURSE "${ODB_COMPILE_OUTPUT_DIR}") file(MAKE_DIRECTORY "${ODB_COMPILE_OUTPUT_DIR}") - foreach(input ${PARAM_FILES}) - get_filename_component(fname "${input}" NAME_WE) - set(outputs) - - foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) - string(REGEX REPLACE ":.*$" "" pfx "${sfx}") - string(REGEX REPLACE "^.*:" "" sfx "${sfx}") - - if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") - set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") - list(APPEND ${outvar} "${output}") - list(APPEND outputs "${output}") - endif() - endforeach() - - if(ODB_COMPILE_DEBUG) - set(_msg "${ODB_EXECUTABLE} ${ODB_ARGS} ${input}") - string(REPLACE ";" " " _msg "${_msg}") - message(STATUS "${_msg}") - endif() - - add_custom_command(OUTPUT ${outputs} - COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} "${input}" - DEPENDS "${input}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - VERBATIM) - endforeach() + if(PARAM_INPUT_NAME) + get_filename_component(fname "${PARAM_INPUT_NAME}" NAME_WE) + set(outputs) + + foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) + string(REGEX REPLACE ":.*$" "" pfx "${sfx}") + string(REGEX REPLACE "^.*:" "" sfx "${sfx}") + + if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") + set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") + list(APPEND ${outvar} "${output}") + list(APPEND outputs "${output}") + endif() + endforeach() + + add_custom_command(OUTPUT ${outputs} + COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} ${PARAM_FILES} + DEPENDS ${PARAM_FILES} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) + else() + foreach(input ${PARAM_FILES}) + get_filename_component(fname "${input}" NAME_WE) + set(outputs) + + foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) + string(REGEX REPLACE ":.*$" "" pfx "${sfx}") + string(REGEX REPLACE "^.*:" "" sfx "${sfx}") + + if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") + set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") + list(APPEND ${outvar} "${output}") + list(APPEND outputs "${output}") + endif() + endforeach() + + if(ODB_COMPILE_DEBUG) + set(_msg "${ODB_EXECUTABLE} ${ODB_ARGS} ${input}") + string(REPLACE ";" " " _msg "${_msg}") + message(STATUS "${_msg}") + endif() + + add_custom_command(OUTPUT ${outputs} + COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} "${input}" + DEPENDS "${input}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) + endforeach() + endif() set(${outvar} ${${outvar}} PARENT_SCOPE) endfunction() diff --git a/employee.h b/employee.h new file mode 100644 index 0000000..bb53937 --- /dev/null +++ b/employee.h @@ -0,0 +1,32 @@ +// file : hello/employee.hxx +// copyright : not copyrighted - public domain + +#ifndef EMPLOYEE_HXX +#define EMPLOYEE_HXX + + +#include +#include // std::size_t + +#include + +#pragma db object +class employee +{ +public: + std::string position() const { return position_; } + unsigned short experience() const { return experience_; } + +private: + friend class odb::access; + + employee () {} + + #pragma db id auto + unsigned long id_; + + std::string position_; + unsigned short experience_; +}; + +#endif // EMPLOYEE_HXX From 98ed46ae5378b4051a240ecc937b8be17e699351 Mon Sep 17 00:00:00 2001 From: dkfsoft Date: Fri, 26 Jun 2015 20:51:02 +0500 Subject: [PATCH 3/8] Prepare AT_ONCE property for cmake build --- CMakeLists.txt | 24 ++++++++++++++++++++++-- driver.cpp | 8 +++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b1b640..385354f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.8.12) project(OdbCMake) +option (AT_ONCE "Build all structures into one file." FALSE) + +set(TARGET_DB "sqlite") + # windows section - generate paths based on ODB_ROOT if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") if(DEFINED ENV{ODB_ROOT}) @@ -16,7 +20,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") -find_package(ODB REQUIRED COMPONENTS mysql OPTIONAL_COMPONENTS pgsql) +find_package(ODB REQUIRED COMPONENTS ${TARGET_DB} OPTIONAL_COMPONENTS pgsql) include(${ODB_USE_FILE}) set(OdbCMake_SOURCES @@ -27,11 +31,27 @@ set(OdbCMake_ODB_HEADERS person.h employee.h) -odb_compile(OdbCMake_SOURCES FILES ${OdbCMake_ODB_HEADERS} DB mysql GENERATE_QUERY GENERATE_SESSION INPUT_NAME "personal") +if (AT_ONCE) + message(STATUS "All database code in one file personal_*") + odb_compile(OdbCMake_SOURCES FILES ${OdbCMake_ODB_HEADERS} DB ${TARGET_DB} GENERATE_QUERY GENERATE_SESSION INPUT_NAME "personal") +else() + odb_compile(OdbCMake_SOURCES FILES ${OdbCMake_ODB_HEADERS} DB ${TARGET_DB} GENERATE_QUERY GENERATE_SESSION) +endif() add_executable(odbcmake ${OdbCMake_SOURCES} ${OdbCMake_ODB_HEADERS}) + +if(AT_ONCE) + # trivial definitions for linux g++ and windows VC++ + # correct for your compiler + if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " -D AT_ONCE ") + else() + set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " /D AT_ONCE ") + endif() +endif() + target_link_libraries(odbcmake ${ODB_LIBRARIES}) target_include_directories(odbcmake diff --git a/driver.cpp b/driver.cpp index 59a07df..f704499 100644 --- a/driver.cpp +++ b/driver.cpp @@ -10,8 +10,14 @@ #include "database.h" // create_database #include "person.h" -#include "person_odb.h" +#include "employee.h" +#ifdef AT_ONCE + #include "personal_odb.h" +#else +#include "person_odb.h" +#include "employee_odb.h" +#endif using namespace std; using namespace odb::core; From 847c5eece7dd64c074e3786913f403dfe165aae1 Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Fri, 26 Jun 2015 20:59:50 +0500 Subject: [PATCH 4/8] Update README --- README | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README b/README index 6036a71..9fca7fe 100644 --- a/README +++ b/README @@ -1,4 +1,11 @@ CMake Find Module and UseFile for ODB. -See example for information on useage, i'm too lazy to write documentation right now. +### Windows ODB installation notes: +Install all odb components into some directory and setup environment variable ODB_ROOT. Directory must contain sub-directories +bin for executables(especially odb.exe) and dlls, include/odb for odb headers and lib for lib files. +For example c:\odb\bin, c\odb\include and c:\odb\lib. Note: when you copy odb.exe - do not copy only exe file - you need all directories from archive. + +### Generate project Windows/Linux +* Generate as usual - each persistent structure in separated file. Simply execute cmake . +* Generate all persistent structures in one file - cmake . -DAT_ONCE=ON From c4805f38c162e93cee7c2dfdf4d18a0272dc3000 Mon Sep 17 00:00:00 2001 From: apavlov at home Date: Sat, 27 Jun 2015 14:44:09 +0500 Subject: [PATCH 5/8] Minor fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 385354f..f5b7f1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ if(AT_ONCE) # trivial definitions for linux g++ and windows VC++ # correct for your compiler if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " -D AT_ONCE ") + set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " -DAT_ONCE ") else() set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " /D AT_ONCE ") endif() From 903f59b91667fb47f096e320a6ef66edc45b541d Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Sat, 27 Jun 2015 14:46:42 +0500 Subject: [PATCH 6/8] Update README --- README | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README b/README index 9fca7fe..9175a3b 100644 --- a/README +++ b/README @@ -1,11 +1,12 @@ CMake Find Module and UseFile for ODB. ### Windows ODB installation notes: -Install all odb components into some directory and setup environment variable ODB_ROOT. Directory must contain sub-directories -bin for executables(especially odb.exe) and dlls, include/odb for odb headers and lib for lib files. +Install all odb components into some directory and setup environment variable ODB_ROOT=your_odb_installation_directory. +Directory must contain sub-directories bin for executables(especially odb.exe) and dlls, +include/odb for odb headers and lib for lib files. For example c:\odb\bin, c\odb\include and c:\odb\lib. Note: when you copy odb.exe - do not copy only exe file - you need all directories from archive. ### Generate project Windows/Linux -* Generate as usual - each persistent structure in separated file. Simply execute cmake . -* Generate all persistent structures in one file - cmake . -DAT_ONCE=ON +* One structure per file. Simply run cmake without options. +* All persistent structures in one file - set option AT_ONCE=ON. For example cmake . -DAT_ONCE=ON From b13c2e07b9e3c549074efdf944700f7f04f6bd95 Mon Sep 17 00:00:00 2001 From: apavlov at home Date: Sat, 27 Jun 2015 23:14:48 +0500 Subject: [PATCH 7/8] Use target_compile_definitions --- CMakeLists.txt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5b7f1e..274bcfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,17 +41,9 @@ endif() add_executable(odbcmake ${OdbCMake_SOURCES} ${OdbCMake_ODB_HEADERS}) - -if(AT_ONCE) - # trivial definitions for linux g++ and windows VC++ - # correct for your compiler - if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " -DAT_ONCE ") - else() - set_target_properties(odbcmake PROPERTIES COMPILE_FLAGS " /D AT_ONCE ") - endif() -endif() - + +target_compile_definitions(odbcmake PUBLIC AT_ONCE) + target_link_libraries(odbcmake ${ODB_LIBRARIES}) target_include_directories(odbcmake From 450e26acbbeeb0df39db058bce836c33f7612a1d Mon Sep 17 00:00:00 2001 From: dkfsoft Date: Sat, 27 Jun 2015 23:28:38 +0500 Subject: [PATCH 8/8] Use tabs, remove odb_root, uncomment lib cache --- CMakeLists.txt | 12 ----- README | 2 +- cmake/Modules/FindODB.cmake | 2 +- cmake/Modules/UseODB.cmake | 98 ++++++++++++++++++------------------- 4 files changed, 51 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 274bcfe..78d76e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,18 +6,6 @@ option (AT_ONCE "Build all structures into one file." FALSE) set(TARGET_DB "sqlite") -# windows section - generate paths based on ODB_ROOT -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - if(DEFINED ENV{ODB_ROOT}) - set(ODB_ROOT $ENV{ODB_ROOT}) - endif(DEFINED ENV{ODB_ROOT}) - message(STATUS "Prepare variables using ODB_ROOT=${ODB_ROOT}") - set(PC_LIBODB_INCLUDE_DIRS "${ODB_ROOT}\\include") - set(PC_LIBODB_LIBRARY_DIRS "${ODB_ROOT}\\lib") - set(ODB_LIBODB_INCLUDE_DIRS "${ODB_ROOT}\\include") - set(ODB_LIBRARY_PATH "${ODB_ROOT}\\lib") -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") find_package(ODB REQUIRED COMPONENTS ${TARGET_DB} OPTIONAL_COMPONENTS pgsql) diff --git a/README b/README index 9175a3b..f2a54d2 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ CMake Find Module and UseFile for ODB. ### Windows ODB installation notes: -Install all odb components into some directory and setup environment variable ODB_ROOT=your_odb_installation_directory. +Install all odb components into some directory and setup environment variable CMAKE_PREFIX_PATH=your_odb_installation_directory. Directory must contain sub-directories bin for executables(especially odb.exe) and dlls, include/odb for odb headers and lib for lib files. For example c:\odb\bin, c\odb\include and c:\odb\lib. Note: when you copy odb.exe - do not copy only exe file - you need all directories from archive. diff --git a/cmake/Modules/FindODB.cmake b/cmake/Modules/FindODB.cmake index e10c102..be00506 100644 --- a/cmake/Modules/FindODB.cmake +++ b/cmake/Modules/FindODB.cmake @@ -69,7 +69,7 @@ endfunction() pkg_check_modules(PC_LIBODB QUIET "libodb") -#set(ODB_LIBRARY_PATH "" CACHE STRING "Common library search hint for all ODB libs") +set(ODB_LIBRARY_PATH "" CACHE STRING "Common library search hint for all ODB libs") find_path(libodb_INCLUDE_DIR NAMES odb/version.hxx diff --git a/cmake/Modules/UseODB.cmake b/cmake/Modules/UseODB.cmake index 760ef3a..e2b6316 100644 --- a/cmake/Modules/UseODB.cmake +++ b/cmake/Modules/UseODB.cmake @@ -141,55 +141,55 @@ function(odb_compile outvar) file(REMOVE_RECURSE "${ODB_COMPILE_OUTPUT_DIR}") file(MAKE_DIRECTORY "${ODB_COMPILE_OUTPUT_DIR}") - if(PARAM_INPUT_NAME) - get_filename_component(fname "${PARAM_INPUT_NAME}" NAME_WE) - set(outputs) - - foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) - string(REGEX REPLACE ":.*$" "" pfx "${sfx}") - string(REGEX REPLACE "^.*:" "" sfx "${sfx}") - - if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") - set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") - list(APPEND ${outvar} "${output}") - list(APPEND outputs "${output}") - endif() - endforeach() - - add_custom_command(OUTPUT ${outputs} - COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} ${PARAM_FILES} - DEPENDS ${PARAM_FILES} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - VERBATIM) - else() - foreach(input ${PARAM_FILES}) - get_filename_component(fname "${input}" NAME_WE) - set(outputs) - - foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) - string(REGEX REPLACE ":.*$" "" pfx "${sfx}") - string(REGEX REPLACE "^.*:" "" sfx "${sfx}") - - if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") - set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") - list(APPEND ${outvar} "${output}") - list(APPEND outputs "${output}") - endif() - endforeach() - - if(ODB_COMPILE_DEBUG) - set(_msg "${ODB_EXECUTABLE} ${ODB_ARGS} ${input}") - string(REPLACE ";" " " _msg "${_msg}") - message(STATUS "${_msg}") - endif() - - add_custom_command(OUTPUT ${outputs} - COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} "${input}" - DEPENDS "${input}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - VERBATIM) - endforeach() - endif() + if(PARAM_INPUT_NAME) + get_filename_component(fname "${PARAM_INPUT_NAME}" NAME_WE) + set(outputs) + + foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) + string(REGEX REPLACE ":.*$" "" pfx "${sfx}") + string(REGEX REPLACE "^.*:" "" sfx "${sfx}") + + if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") + set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") + list(APPEND ${outvar} "${output}") + list(APPEND outputs "${output}") + endif() + endforeach() + + add_custom_command(OUTPUT ${outputs} + COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} ${PARAM_FILES} + DEPENDS ${PARAM_FILES} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) + else() + foreach(input ${PARAM_FILES}) + get_filename_component(fname "${input}" NAME_WE) + set(outputs) + + foreach(sfx ${ODB_COMPILE_FILE_SUFFIX}) + string(REGEX REPLACE ":.*$" "" pfx "${sfx}") + string(REGEX REPLACE "^.*:" "" sfx "${sfx}") + + if(NOT "${PARAM_MULTI_DATABASE}" MATCHES "static" OR NOT "${pfx}" MATCHES "common") + set(output "${ODB_COMPILE_OUTPUT_DIR}/${fname}${sfx}${ODB_COMPILE_SOURCE_SUFFIX}") + list(APPEND ${outvar} "${output}") + list(APPEND outputs "${output}") + endif() + endforeach() + + if(ODB_COMPILE_DEBUG) + set(_msg "${ODB_EXECUTABLE} ${ODB_ARGS} ${input}") + string(REPLACE ";" " " _msg "${_msg}") + message(STATUS "${_msg}") + endif() + + add_custom_command(OUTPUT ${outputs} + COMMAND ${ODB_EXECUTABLE} ${ODB_ARGS} "${input}" + DEPENDS "${input}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) + endforeach() + endif() set(${outvar} ${${outvar}} PARENT_SCOPE) endfunction()