Skip to content

Commit

Permalink
CMakeFile lists refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymoteusz Blazejczyk committed Feb 18, 2017
1 parent a5de785 commit 7779192
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 180 deletions.
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Expand Up @@ -29,6 +29,10 @@

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
endif()

add_subdirectory(simple)
add_subdirectory(string)
add_subdirectory(factorial)
Expand Down
14 changes: 2 additions & 12 deletions examples/evil_defines/CMakeLists.txt
Expand Up @@ -27,15 +27,5 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(example-evil-defines
evil_defines.cpp
)

set_target_properties(example-evil-defines PROPERTIES OUTPUT_NAME evil_defines)
target_link_libraries(example-evil-defines utest-main utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(evil_defines.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_evil_defines evil_defines.cpp)
target_link_libraries(example_evil_defines utest-main utest)
14 changes: 2 additions & 12 deletions examples/factorial/CMakeLists.txt
Expand Up @@ -27,15 +27,5 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(example-factorial
factorial.cpp
)

set_target_properties(example-factorial PROPERTIES OUTPUT_NAME factorial)
target_link_libraries(example-factorial utest-main utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(factorial.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_factorial factorial.cpp)
target_link_libraries(example_factorial utest-main utest)
14 changes: 2 additions & 12 deletions examples/files/CMakeLists.txt
Expand Up @@ -31,15 +31,5 @@ if (NOT UNIX)
return()
endif()

add_executable(example-files
files.cpp
)

set_target_properties(example-files PROPERTIES OUTPUT_NAME files)
target_link_libraries(example-files utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(files.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_files files.cpp)
target_link_libraries(example_files utest)
14 changes: 2 additions & 12 deletions examples/json/CMakeLists.txt
Expand Up @@ -27,15 +27,5 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(example-json
json.cpp
)

set_target_properties(example-json PROPERTIES OUTPUT_NAME json)
target_link_libraries(example-json utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(json.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_json json.cpp)
target_link_libraries(example_json utest)
14 changes: 2 additions & 12 deletions examples/simple/CMakeLists.txt
Expand Up @@ -27,15 +27,5 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(example-simple
simple.cpp
)

set_target_properties(example-simple PROPERTIES OUTPUT_NAME simple)
target_link_libraries(example-simple utest-main utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(simple.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_simple simple.cpp)
target_link_libraries(example_simple utest-main utest)
14 changes: 2 additions & 12 deletions examples/string/CMakeLists.txt
Expand Up @@ -27,15 +27,5 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(example-string
string.cpp
)

set_target_properties(example-string PROPERTIES OUTPUT_NAME string)
target_link_libraries(example-string utest-main utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(string.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_string string.cpp)
target_link_libraries(example_string utest-main utest)
14 changes: 2 additions & 12 deletions examples/tcp/CMakeLists.txt
Expand Up @@ -31,15 +31,5 @@ if (NOT UNIX)
return()
endif()

add_executable(example-tcp
tcp.cpp
)

set_target_properties(example-tcp PROPERTIES OUTPUT_NAME tcp)
target_link_libraries(example-tcp utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(tcp.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_tcp tcp.cpp)
target_link_libraries(example_tcp utest)
14 changes: 2 additions & 12 deletions examples/udp/CMakeLists.txt
Expand Up @@ -31,15 +31,5 @@ if (NOT UNIX)
return()
endif()

add_executable(example-udp
udp.cpp
)

set_target_properties(example-udp PROPERTIES OUTPUT_NAME udp)
target_link_libraries(example-udp utest)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(udp.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
add_executable(example_udp udp.cpp)
target_link_libraries(example_udp utest)
5 changes: 5 additions & 0 deletions tests/CMakeLists.txt
Expand Up @@ -29,8 +29,13 @@

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
endif()

add_subdirectory(positive)
add_subdirectory(negative)
add_subdirectory(test_thread)
add_subdirectory(test_writer)
add_subdirectory(test_reporter)
add_subdirectory(color)
16 changes: 3 additions & 13 deletions tests/color/CMakeLists.txt
Expand Up @@ -27,20 +27,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(test-color
color.cpp
)

set_target_properties(test-color PROPERTIES OUTPUT_NAME test_color)
target_link_libraries(test-color utest-main utest)
add_executable(test_color color.cpp)
target_link_libraries(test_color utest-main utest)

if (DEFINED TEST_RUNNER)
add_test(NAME test-color COMMAND ${TEST_RUNNER}
add_test(NAME test_color COMMAND ${TEST_RUNNER}
${CMAKE_BINARY_DIR}/tests/test_color)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(color.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
13 changes: 3 additions & 10 deletions tests/negative/CMakeLists.txt
Expand Up @@ -27,21 +27,14 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(test-negative
add_executable(test_negative
negative.cpp
negative_main.cpp
)

set_target_properties(test-negative PROPERTIES OUTPUT_NAME test_negative)
target_link_libraries(test-negative utest)
target_link_libraries(test_negative utest)

if (DEFINED TEST_RUNNER)
add_test(NAME test-negative COMMAND ${TEST_RUNNER}
add_test(NAME test_negative COMMAND ${TEST_RUNNER}
${CMAKE_BINARY_DIR}/tests/test_negative)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(negative.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
16 changes: 3 additions & 13 deletions tests/positive/CMakeLists.txt
Expand Up @@ -27,20 +27,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(test-positive
positive.cpp
)

set_target_properties(test-positive PROPERTIES OUTPUT_NAME test_positive)
target_link_libraries(test-positive utest-main utest)
add_executable(test_positive positive.cpp)
target_link_libraries(test_positive utest-main utest)

if (DEFINED TEST_RUNNER)
add_test(NAME test-positive COMMAND ${TEST_RUNNER}
add_test(NAME test_positive COMMAND ${TEST_RUNNER}
${CMAKE_BINARY_DIR}/tests/test_positive)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(positive.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
18 changes: 3 additions & 15 deletions tests/test_reporter/CMakeLists.txt
Expand Up @@ -27,27 +27,15 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

add_executable(test-reporter-json
add_executable(test_reporter_json
json.cpp
../positive/positive.cpp
../negative/negative.cpp
)

set_target_properties(test-reporter-json PROPERTIES
OUTPUT_NAME test_reporter_json)

target_link_libraries(test-reporter-json utest)
target_link_libraries(test_reporter_json utest)

if (DEFINED TEST_RUNNER)
add_test(NAME test-reporter-json COMMAND ${TEST_RUNNER}
add_test(NAME test_reporter_json COMMAND ${TEST_RUNNER}
${CMAKE_BINARY_DIR}/tests/test_reporter_json)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(
../positive/positive.cpp
../negative/negative.cpp
PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()
36 changes: 36 additions & 0 deletions tests/test_thread/CMakeLists.txt
@@ -0,0 +1,36 @@
# Copyright (c) 2017, Tymoteusz Blazejczyk
# 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.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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.

add_executable(test_thread_generic generic.cpp)
target_link_libraries(test_thread_generic utest)

if (DEFINED TEST_RUNNER)
add_test(NAME test_thread_generic COMMAND ${TEST_RUNNER}
${CMAKE_BINARY_DIR}/tests/test_thread_generic)
endif()
54 changes: 54 additions & 0 deletions tests/test_thread/generic.cpp
@@ -0,0 +1,54 @@
/*!
* @copright
* Copyright (c) 2017, Tymoteusz Blazejczyk
* All rights reserved.
*
* @copright
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* @copright
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* @copright
* * 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.
*
* @copright
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* @copright
* 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.
*
* @file tests/test_thread/generic.cpp
*
* @brief Main implementation
*/

#include <utest/test_thread/generic.hpp>

#include <cstdlib>
#include <memory>

using namespace utest;

int main() {
{
std::unique_ptr<test_thread::Generic> ptr{new test_thread::Generic{}};
}
return EXIT_SUCCESS;
}
16 changes: 3 additions & 13 deletions tests/test_writer/CMakeLists.txt
Expand Up @@ -31,20 +31,10 @@ if (UNIX)
add_subdirectory(linux)
endif()

add_executable(test-writer-file
file.cpp
)

set_target_properties(test-writer-file PROPERTIES OUTPUT_NAME test_writer_file)
target_link_libraries(test-writer-file utest)
add_executable(test_writer_file file.cpp)
target_link_libraries(test_writer_file utest)

if (DEFINED TEST_RUNNER)
add_test(NAME test-writer-file COMMAND ${TEST_RUNNER}
add_test(NAME test_writer_file COMMAND ${TEST_RUNNER}
${CMAKE_BINARY_DIR}/tests/test_writer_file)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(file.cpp PROPERTIES
COMPILE_FLAGS "-Wno-global-constructors"
)
endif()

0 comments on commit 7779192

Please sign in to comment.