-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
85 lines (73 loc) · 3.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
cmake_minimum_required(VERSION 3.25)
project(AlgoVisualizer)
set(CMAKE_CXX_STANDARD 23)
find_package(PkgConfig REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_ttf QUIET)
if(SDL2_TTF_FOUND)
message(STATUS "Using SDL2_ttf from find_package")
set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARIES})
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
message(STATUS "Using SDL2_ttf from pkg-config")
endif()
find_package(Boost REQUIRED COMPONENTS container graph log)
find_package(fmt REQUIRED)
find_package(CryptoPP QUIET)
if(CryptoPP_FOUND)
message(STATUS "Found CryptoPP via find_package")
else()
pkg_check_modules(CryptoPP REQUIRED libcryptopp)
message(STATUS "Found CryptoPP via pkg-config")
endif()
find_package(Catch2 QUIET)
if(Catch2_FOUND)
message(STATUS "Using Catch2 from find_package")
else()
pkg_search_module(CATCH2 REQUIRED IMPORTED_TARGET catch2)
message(STATUS "Using Catch2 from pkg-config")
endif()
find_package(sodium QUIET)
if(sodium_FOUND)
message(STATUS "Using libsodium from find_package")
else()
pkg_check_modules(sodium REQUIRED libsodium)
message(STATUS "Using libsodium from pkg-config")
endif()
message("SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}")
message("SDL2_LIBRARIES: ${SDL2_LIBRARIES}")
message("SDL2_TTF_INCLUDE_DIRS: ${SDL2_TTF_INCLUDE_DIRS}")
message("SDL2_TTF_LIBRARIES: ${SDL2_TTF_LIBRARIES}")
message("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message("Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Catch2 Version: ${Catch2_VERSION}")
option(ENABLE_LOGGING "Enable detailed logging" OFF)
if(ENABLE_LOGGING)
add_compile_definitions(ENABLE_LOGGING)
endif()
#if(NOT MSVC AND CMAKE_BUILD_TYPE MATCHES Debug)
# set(SANITIZE_FLAGS "-fsanitize=address")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SANITIZE_FLAGS}")
# set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${SANITIZE_FLAGS}")
#endif()
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${sodium_INCLUDE_DIRS})
add_library(boost_container_wrapper INTERFACE)
target_link_libraries(boost_container_wrapper INTERFACE Boost::container)
# main
add_executable(AlgoVisualizer main.cpp Visualizer.cpp Visualizer.hpp Maze.cpp Maze.hpp FPSCounter.cpp FPSCounter.hpp Constants.hpp test_1.cpp Square.cpp Square.hpp IRenderable.hpp CustomCursor.cpp CustomCursor.h Tetris.cpp Tetris.h Piece.cpp Piece.h Block.cpp Block.h BubbleSort.cpp BubbleSort.h InsertionSort.cpp InsertionSort.h)
target_link_libraries(AlgoVisualizer ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES} Boost::graph Boost::log boost_container_wrapper fmt::fmt ${CryptoPP_LIBRARIES} ${sodium_LIBRARIES})
#test
add_executable(tests test_1.cpp)
target_compile_definitions(tests PRIVATE TEST_BUILD)
if(Catch2_FOUND)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
else()
target_link_libraries(tests PRIVATE PkgConfig::CATCH2)
endif()
if(MSVC)
target_compile_options(AlgoVisualizer PRIVATE /W4 /WX /w14242 /w14254 /w14263 /w14265 /w14287 /we4289 /w14296 /w14311 /w14545 /w14546 /w14547 /w14549 /w14555 /w14619 /w14640 /w14826 /w14905 /w14906 /w14928 /w15038)
else()
target_compile_options(AlgoVisualizer PRIVATE -Wall -Wextra -pedantic -Werror -Weffc++ -Wconversion -Wsign-conversion -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wdouble-promotion -Wformat=2 -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual -Wwrite-strings -Wmissing-declarations -Woverloaded-virtual -Wnoexcept -Wnon-virtual-dtor -Wstrict-overflow=5 -Wswitch-default -Wswitch-enum -Winit-self -Wredundant-decls -Wundef -Winline -Wunreachable-code -Wdeprecated -Wsuggest-override)
endif()