Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit c65fe4b

Browse files
committed
Add Debug and Release configuration
1 parent 14c74ca commit c65fe4b

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

CMakeLists.txt

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@ set(CMAKE_CXX_STANDARD 20)
1010
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1111
set(BOOST_VERSION_REQUIRED "1.83.0")
1212

13+
include(${CMAKE_SOURCE_DIR}/CMakeHelpers.cmake)
14+
1315
# OPTIONS ====================================
14-
option(BUILD_TESTS "Build tests" OFF)
15-
add_definitions(-DBUILD_TESTS)
16+
if(NOT CMAKE_BUILD_TYPE)
17+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
18+
endif()
19+
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
1620

1721
# XAPI =======================================
18-
include(${CMAKE_SOURCE_DIR}/CMakeHelpers.cmake)
19-
2022
helper_FIND_BOOST_LIBS()
2123
helper_FIND_OPENSSL_LIB()
22-
2324
add_subdirectory(xapi)
2425

2526
# TESTS ======================================
26-
if(BUILD_TESTS)
27+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
28+
helper_FIND_GTEST_LIBS()
29+
add_definitions(-DENABLE_TEST)
2730
add_subdirectory(test)
2831
endif()

test/CMakeLists.txt

-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
helper_FIND_GTEST_LIBS()
21
enable_testing()
32

43
set( SOURCES
@@ -12,15 +11,6 @@ add_executable( tests
1211
${SOURCES}
1312
)
1413

15-
target_compile_options(tests PRIVATE
16-
-Wall
17-
-Wextra
18-
-Wpedantic
19-
-Werror
20-
-Wno-unused-parameter
21-
-Wno-missing-field-initializers
22-
)
23-
2414
target_include_directories(tests PRIVATE mocks)
2515
target_link_libraries(tests PRIVATE
2616
${GTEST_LIBRARIES}

test/TestXStationClient.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1377,5 +1377,4 @@ TEST_F(XStationClientTest, tradeTransactionStatus_exception)
13771377
EXPECT_THROW(result = runAwaitable(client->tradeTransactionStatus(order)), exception::ConnectionClosed);
13781378
}
13791379

1380-
13811380
} // namespace xapi

xapi/CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ set(XAPI_SOURCES
1717

1818
add_library(Xapi SHARED ${XAPI_SOURCES})
1919

20-
target_compile_options(Xapi PRIVATE
20+
# TARGET SETUP OPTIONS ========================================
21+
set(COMMON_FLAGS
2122
-Wall
2223
-Werror
2324
-Wpedantic
2425
-Wextra
25-
-O3
2626
)
2727

28+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
29+
list(APPEND COMMON_FLAGS -O3)
30+
else()
31+
list(APPEND COMMON_FLAGS -O0 -g)
32+
endif()
33+
target_compile_options(Xapi PRIVATE ${COMMON_FLAGS})
34+
35+
# TARGET LINK OPTIONS ========================================
2836
target_link_libraries(Xapi PRIVATE
2937
Boost::system
3038
Boost::url

0 commit comments

Comments
 (0)