mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
build examples to a single, combined executable
This commit is contained in:
parent
b99e2f653b
commit
ec20a8a627
@ -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)
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "MockDb.h"
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
|
||||
int main()
|
||||
int insert(int, char**)
|
||||
{
|
||||
MockDb db;
|
||||
|
||||
@ -64,4 +64,5 @@ int main()
|
||||
pi.params.feature = true;
|
||||
|
||||
db(pi);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "MockDb.h"
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "MockDb.h"
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user