1+ cmake_minimum_required (VERSION 3.10.0)
2+ project (CppRl
3+ LANGUAGES CXX
4+ VERSION 1.0.0
5+ DESCRIPTION "Reinforcement learning in C++ using PyTorch"
6+ )
7+
8+ # Project-wide properties
9+ set (CMAKE_CXX_STANDARD 17)
10+
11+ # Cppcheck
12+ list (APPEND CPPCHECK_ARGS
13+ --enable=warning
14+ --std=c++14
15+ --verbose
16+ --force
17+ --quiet
18+ --inline-suppr
19+ --error-exitcode=1
20+ --language =c++
21+ --config-exclude =${CMAKE_CURRENT_LIST_DIR} /src/third_party
22+ --config-exclude =${CMAKE_CURRENT_LIST_DIR} /lib
23+ --suppressions-list=${CMAKE_CURRENT_LIST_DIR} /CppCheckSuppressions.txt
24+ -I ${CMAKE_CURRENT_LIST_DIR} /src
25+ -I ${CMAKE_CURRENT_LIST_DIR} /include
26+ -I ${CMAKE_CURRENT_LIST_DIR} /lib/spdlog/include
27+ -I ${CMAKE_CURRENT_LIST_DIR} /example
28+ ${CMAKE_CURRENT_LIST_DIR} /src
29+ ${CMAKE_CURRENT_LIST_DIR} /example
30+ )
31+
32+ add_custom_target (
33+ check
34+ COMMAND cppcheck ${CPPCHECK_ARGS}
35+ COMMENT "Running Cppcheck"
36+ )
37+
38+ # Dependencies
39+ ## PyTorch
40+ find_package (Torch REQUIRED)
41+ if (TORCH_CXX_FLAGS)
42+ set (CMAKE_CXX_FLAGS ${TORCH_CXX_FLAGS} )
43+ endif ()
44+ ## Spdlog
45+ add_subdirectory (lib/spdlog)
46+
47+ # Define targets
48+ add_library (cpprl STATIC "" )
49+ target_compile_definitions (cpprl PRIVATE DOCTEST_CONFIG_DISABLE)
50+ option (CPPRL_BUILD_TESTS "Whether or not to build the CppRl tests" ON )
51+ if (CPPRL_BUILD_TESTS)
52+ add_executable (cpprl_tests "" )
53+ endif (CPPRL_BUILD_TESTS)
54+
55+ # Enable all warnings
56+ if (MSVC )
57+ target_compile_options (cpprl PRIVATE /W4 /WX)
58+ else (MSVC )
59+ target_compile_options (cpprl PRIVATE -Wall -Wextra -pedantic)
60+ endif (MSVC )
61+
62+ # Includes
63+ set (CPPRL_INCLUDE_DIRS
64+ include
65+ src
66+ lib/spdlog/include
67+ ${TORCH_INCLUDE_DIRS}
68+ )
69+ target_include_directories (cpprl PRIVATE ${CPPRL_INCLUDE_DIRS} )
70+ target_include_directories (cpprl_tests PRIVATE ${CPPRL_INCLUDE_DIRS} )
71+
72+ # Linking
73+ target_link_libraries (cpprl torch ${TORCH_LIBRARIES} )
74+ target_link_libraries (cpprl_tests torch ${TORCH_LIBRARIES} )
75+
76+ # Example
77+ add_subdirectory (example)
78+
79+ # Recurse into source tree
80+ add_subdirectory (src)
0 commit comments