@@ -4,15 +4,9 @@ project(tradercpp)
44set (CMAKE_CXX_STANDARD 23)
55set (CMAKE_CXX_STANDARD_REQUIRED YES )
66
7- # Define the source files
8- file (GLOB_RECURSE SOURCES "src/*.cpp" )
9-
10- # Create the executable
11- add_executable (tradercpp ${SOURCES} )
12-
137############################################
14-
158# Conan-generated toolchain setup
9+
1610include (${CMAKE_BINARY_DIR } /conan_toolchain.cmake OPTIONAL RESULT_VARIABLE _found_toolchain )
1711if (_found_toolchain)
1812 message (STATUS "Conan toolchain included" )
@@ -21,18 +15,46 @@ endif()
2115# Find packages from Conan
2216find_package (concurrentqueue REQUIRED )
2317find_package (ftxui REQUIRED )
18+ find_package (GTest REQUIRED )
2419find_package (OpenSSL REQUIRED )
2520find_package (quickfix REQUIRED CONFIG )
2621find_package (libsodium REQUIRED )
2722find_package (spdlog REQUIRED )
2823
29- # Link them to the executable
30- target_link_libraries (tradercpp PRIVATE
31- concurrentqueue::concurrentqueue
32- ftxui::ftxui
33- OpenSSL::SSL
34- OpenSSL::Crypto
35- quickfix::quickfix
36- libsodium::libsodium
37- spdlog::spdlog
24+ ############################################
25+ # Collect source files
26+
27+ file (GLOB_RECURSE ALL_SOURCES "src/*.cpp" )
28+ # Separate main.cpp from the rest of the sources
29+ list (FILTER ALL_SOURCES EXCLUDE REGEX ".*main\\ .cpp$" )
30+ set (SOURCES ${ALL_SOURCES} )
31+
32+ ############################################
33+ # Create core logic library
34+ add_library (traderlib STATIC ${SOURCES} )
35+
36+ # TODO: MAKE CONDITIONAL
37+ # Add coverage flags to the traderlib target
38+ target_compile_options (traderlib PRIVATE -O0 -g --coverage )
39+ target_link_libraries (traderlib PRIVATE --coverage )
40+
41+ # Link dependencies to the library (so both exe and tests get them)
42+ target_link_libraries (traderlib PUBLIC
43+ concurrentqueue::concurrentqueue
44+ ftxui::ftxui
45+ OpenSSL::SSL
46+ OpenSSL::Crypto
47+ quickfix::quickfix
48+ libsodium::libsodium
49+ spdlog::spdlog
3850)
51+
52+ ############################################
53+ # Create main executable
54+ add_executable (tradercpp "src/main.cpp" )
55+ target_link_libraries (tradercpp PRIVATE traderlib )
56+
57+ ############################################
58+ # Enable `ctest`
59+ enable_testing ()
60+ add_subdirectory (tests )
0 commit comments