Skip to content

Commit 96367d1

Browse files
committed
Refactoring CMakeLists.txt file to reduce the number of lines.
1 parent 7535fca commit 96367d1

File tree

1 file changed

+25
-62
lines changed

1 file changed

+25
-62
lines changed

libs/network/test/CMakeLists.txt

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,68 +15,31 @@ set(Boost_USE_STATIC_LIBS ON)
1515
set(Boost_USE_MULTITHREADED ON)
1616

1717
if (Boost_FOUND)
18-
set_source_files_properties(
19-
http_incremental_parser.cpp hello_world.cpp
20-
http_1_0_test.cpp http_1_1_test.cpp
21-
http_localhost_tests.cpp https_localhost_tests.cpp
22-
message_test.cpp http_message_twst.cpp
23-
message_transform_test.cpp url_test.cpp
24-
PROPERTIES COMPILE_FLAGS "-Wall"
18+
set(
19+
TESTS
20+
http_incremental_parser
21+
hello_world
22+
http_1_0_test
23+
http_1_1_test
24+
http_localhost_tests
25+
https_localhost_tests
26+
message_test
27+
http_message_test
28+
message_transform_test
29+
url_test
30+
utils_thread_pool
2531
)
26-
add_executable(cpp-netlib-http_incremental_parser http_incremental_parser.cpp)
27-
add_executable(cpp-netlib-hello_world hello_world.cpp)
28-
add_executable(cpp-netlib-http_1_0_test http_1_0_test.cpp)
29-
add_executable(cpp-netlib-http_1_1_test http_1_1_test.cpp)
30-
add_executable(cpp-netlib-http_localhost_tests http_localhost_tests.cpp)
31-
add_executable(cpp-netlib-https_localhost_tests https_localhost_tests.cpp)
32-
add_executable(cpp-netlib-message_test message_test.cpp)
33-
add_executable(cpp-netlib-http_message_test http_message_test.cpp)
34-
add_executable(cpp-netlib-message_transform_test message_transform_test.cpp)
35-
add_executable(cpp-netlib-url_test url_test.cpp)
36-
add_executable(cpp-netlib-utils_thread_pool utils_thread_pool.cpp)
37-
target_link_libraries(cpp-netlib-http_incremental_parser ${CMAKE_THREAD_LIBS_INIT} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
38-
target_link_libraries(cpp-netlib-hello_world ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_THREAD_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
39-
target_link_libraries(cpp-netlib-http_1_0_test ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
40-
target_link_libraries(cpp-netlib-http_1_1_test ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
41-
target_link_libraries(cpp-netlib-http_message_test ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
42-
target_link_libraries(cpp-netlib-message_test ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
43-
target_link_libraries(cpp-netlib-message_transform_test ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
44-
target_link_libraries(cpp-netlib-http_localhost_tests ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
45-
target_link_libraries(cpp-netlib-https_localhost_tests ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
46-
target_link_libraries(cpp-netlib-url_test ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
47-
target_link_libraries(cpp-netlib-utils_thread_pool ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
48-
if (OPENSSL_FOUND)
49-
target_link_libraries(cpp-netlib-hello_world ${OPENSSL_LIBRARIES})
50-
target_link_libraries(cpp-netlib-http_1_0_test ${OPENSSL_LIBRARIES})
51-
target_link_libraries(cpp-netlib-http_1_1_test ${OPENSSL_LIBRARIES})
52-
target_link_libraries(cpp-netlib-http_message_test ${OPENSSL_LIBRARIES} )
53-
target_link_libraries(cpp-netlib-message_test ${OPENSSL_LIBRARIES} )
54-
target_link_libraries(cpp-netlib-message_transform_test ${OPENSSL_LIBRARIES} )
55-
target_link_libraries(cpp-netlib-http_localhost_tests ${OPENSSL_LIBRARIES} )
56-
target_link_libraries(cpp-netlib-https_localhost_tests ${OPENSSL_LIBRARIES} )
57-
target_link_libraries(cpp-netlib-url_test ${OPENSSL_LIBRARIES} )
58-
endif()
59-
set_target_properties(
60-
cpp-netlib-http_incremental_parser
61-
cpp-netlib-hello_world
62-
cpp-netlib-http_1_0_test
63-
cpp-netlib-http_1_1_test
64-
cpp-netlib-message_test
65-
cpp-netlib-http_message_test
66-
cpp-netlib-message_transform_test
67-
cpp-netlib-http_localhost_tests
68-
cpp-netlib-https_localhost_tests
69-
cpp-netlib-url_test
70-
cpp-netlib-utils_thread_pool
71-
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ../../../build/tests)
72-
add_test(cpp-netlib-http_incremental_parser ../../../build/tests/cpp-netlib-http_incremental_parser)
73-
add_test(cpp-netlib-hello_world python httplib_acceptance.py ../../../build/tests/cpp-netlib-hello_world ../../../build/tests/cpp-netlib-hello_world.passed)
74-
add_test(cpp-netlib-http_1_0_test ../../../build/tests/cpp-netlib-http_1_0_test)
75-
add_test(cpp-netlib-http_1_1_test ../../../build/tests/cpp-netlib-http_1_1_test)
76-
add_test(cpp-netlib-http_localhost_tests ../../../build/tests/cpp-netlib-http_localhost_tests)
77-
add_test(cpp-netlib-https_localhost_tests ../../../build/tests/cpp-netlib-https_localhost_tests)
78-
add_test(cpp-netlib-message_test ../../../build/tests/cpp-netlib-message_test)
79-
add_test(cpp-netlib-http_message_test ../../../build/tests/cpp-netlib-http_message_test)
80-
add_test(cpp-netlib-url_test ../../../build/tests/cpp-netlib-url_test)
32+
foreach (test ${TESTS})
33+
set_source_files_properties(${test}.cpp
34+
PROPERTIES COMPILE_FLAGS "-Wall")
35+
add_executable(cpp-netlib-${test} ${test}.cpp)
36+
target_link_libraries(cpp-netlib-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
37+
if (OPENSSL_FOUND)
38+
target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES})
39+
endif()
40+
set_target_properties(cpp-netlib-${test}
41+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ../../../build/tests)
42+
add_test(cpp-netlib-${test} ../../../build/tests/cpp-netlib-${test})
43+
endforeach (test)
8144
endif()
8245

0 commit comments

Comments
 (0)