-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
63 lines (52 loc) · 1.87 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
cmake_minimum_required(VERSION 3.15)
project(Phyzzy LANGUAGES C CXX)
# Set C and C++ standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Define include directories using target_include_directories
# Add both the root "include" directory and "include/phyzzy"
set(PHYZZY_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/phyzzy
)
# Collect source files
set(PHYZZY_SOURCES
src/physics.c
src/physicsbody_physics.c
src/physicsbody.cpp
)
set(PHYZZY_HEADERS
include/phyzzy/physics.h
include/phyzzy/physicsbody_physics.h
include/phyzzy/physicsbody.h
include/math_types.h
include/physics_types.h
include/types.h
include/vector_math.h
)
# Create a static library
add_library(PhyzzyLib STATIC ${PHYZZY_SOURCES} ${PHYZZY_HEADERS})
# Add include directories to the target
target_include_directories(PhyzzyLib PUBLIC ${PHYZZY_INCLUDE_DIRS})
# Specify the output directory for the compiled library
set_target_properties(PhyzzyLib PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/PhyzzyLib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/PhyzzyLib
)
# Add warnings and additional compiler flags for safety
if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(PhyzzyLib PRIVATE -Wall -Wextra -Werror -pedantic)
elseif (CMAKE_C_COMPILER_ID MATCHES "MSVC")
target_compile_options(PhyzzyLib PRIVATE /W4 /WX)
endif()
# Optionally, add an executable for testing
option(BUILD_TESTS "Build test executable" OFF)
if (BUILD_TESTS)
add_executable(test_phyzzy test/test_main.c)
target_link_libraries(test_phyzzy PRIVATE PhyzzyLib)
target_include_directories(test_phyzzy PRIVATE ${PHYZZY_INCLUDE_DIRS})
endif()
# Export the library to allow it to be used as a submodule
export(TARGETS PhyzzyLib FILE PhyzzyLibTargets.cmake)