diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 33b8e65f..589a0b52 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,23 +1,51 @@ +# Copyright (c) 2013-2015, Roland Bock +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -macro (build arg) - # Add headers to sources to enable file browsing in IDEs - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests") - add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_SOURCE_DIR}/../tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h") - add_test("${arg}" "Sqlpp11Example${arg}") -endmacro () +include_directories(../tests) + +set(example_names + #sample + insert + update + remove + select + ) -#build(sample) -build(insert) -build(update) -build(remove) -build(select) find_package(Boost 1.50) if(Boost_FOUND) - MESSAGE(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) - build(ppgen) + list(APPEND example_names ppgen) endif() +create_test_sourcelist(example_sources example_main.cpp ${example_names}) +add_executable(sqlpp11_examples ${example_sources}) + +foreach(example IN LISTS example_names) + add_test(NAME sqlpp11.examples.${example} + COMMAND sqlpp11_examples ${example} + ) +endforeach() #find_package(PythonInterp REQUIRED) diff --git a/examples/insert.cpp b/examples/insert.cpp index 2cf32f68..6aa85f9c 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int main() +int insert(int, char**) { MockDb db; @@ -64,4 +64,5 @@ int main() pi.params.feature = true; db(pi); + return 0; } diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp index d865f4e8..48ca5610 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -61,7 +61,7 @@ SQLPP_DECLARE_TABLE( (fatal, bool , SQLPP_NOT_NULL ) ) -int main() +int ppgen(int, char**) { MockDb db; tab_person::tab_person p; @@ -97,4 +97,5 @@ int main() pi.params.feature = true; db(pi); + return 0; } diff --git a/examples/remove.cpp b/examples/remove.cpp index 8bec39c3..3788e7e8 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int main() +int remove(int, char**) { MockDb db; @@ -37,4 +37,5 @@ int main() db(remove_from(p) .using_(p, q) .where(p.feature == q.id and q.fatal == true)); + return 0; } diff --git a/examples/select.cpp b/examples/select.cpp index 10d756bb..8607f7a1 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -36,7 +36,7 @@ SQLPP_ALIAS_PROVIDER(cheesecake) -int main() +int select(int, char**) { static constexpr bool some_condition = true; static constexpr bool some_other_condition = false; @@ -153,4 +153,5 @@ int main() + return 0; } diff --git a/examples/update.cpp b/examples/update.cpp index e9bad556..ed3de0a2 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int main() +int update(int, char**) { MockDb db; @@ -35,4 +35,5 @@ int main() //test::TabFeature q; db(update(p).set(p.feature = 7).where(p.id == 23)); + return 0; }