-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (49 loc) · 1.83 KB
/
CMakeLists.txt
File metadata and controls
59 lines (49 loc) · 1.83 KB
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
cmake_minimum_required(VERSION 3.10)
project(PhysicsEngine VERSION 0.1 LANGUAGES CXX)
# Allow the user to override the C++ standard; default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
# Default to Release if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
# Add a simple option to enable extra warnings
option(ENABLE_PEDANTIC "Enable pedantic warnings and extra warnings" OFF)
if(ENABLE_PEDANTIC)
if(MSVC)
add_compile_options(/W4 /permissive-)
else()
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
endif()
endif()
set(SOURCES
${PROJECT_SOURCE_DIR}/main.cpp
)
add_executable(physics_engine ${SOURCES})
# Ensure target uses the requested C++ standard
target_compile_features(physics_engine PRIVATE cxx_std_17)
target_include_directories(physics_engine PRIVATE ${PROJECT_SOURCE_DIR})
# Try to find SDL2 via CMake package first, then fall back to pkg-config
find_package(SDL2 REQUIRED)
if(TARGET SDL2::SDL2)
target_link_libraries(physics_engine PRIVATE SDL2::SDL2)
target_include_directories(physics_engine PRIVATE ${SDL2_INCLUDE_DIRS})
else()
# Fallback: try pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2_PKG REQUIRED sdl2)
if(SDL2_PKG_FOUND)
target_include_directories(physics_engine PRIVATE ${SDL2_PKG_INCLUDE_DIRS})
target_link_libraries(physics_engine PRIVATE ${SDL2_PKG_LIBRARIES})
target_compile_options(physics_engine PRIVATE ${SDL2_PKG_CFLAGS_OTHER})
else()
message(FATAL_ERROR "SDL2 not found. Install SDL2 development headers or provide SDL2 package for CMake.")
endif()
endif()
install(TARGETS physics_engine
RUNTIME DESTINATION bin
)
message(STATUS "Configured ${PROJECT_NAME} v${PROJECT_VERSION}")