Modernize CMake configs

This commit is contained in:
Graham Pentheny
2026-02-07 22:44:12 -05:00
parent f9addb2427
commit ace5d51d99
6 changed files with 118 additions and 66 deletions

View File

@@ -1,5 +1,4 @@
file(GLOB SOURCES Source/*.cpp)
add_library(DebugUtils ${SOURCES})
add_library(DebugUtils)
add_library(RecastNavigation::DebugUtils ALIAS DebugUtils)
set_target_properties(DebugUtils PROPERTIES
@@ -13,13 +12,18 @@ set_target_properties(DebugUtils PROPERTIES
CXX_EXTENSIONS OFF # Disable compiler-specific extensions
)
# Set include path
set(DebugUtils_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include")
target_include_directories(DebugUtils PUBLIC
"$<BUILD_INTERFACE:${DebugUtils_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation>"
)
target_sources(DebugUtils PRIVATE
Source/DebugDraw.cpp
Source/DetourDebugDraw.cpp
Source/RecastDebugDraw.cpp
Source/RecastDump.cpp
)
# Set linkages
target_link_libraries(DebugUtils Recast Detour DetourTileCache)
install(TARGETS DebugUtils
@@ -30,8 +34,11 @@ install(TARGETS DebugUtils
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
)
file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation)
install(DIRECTORY Include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
FILES_MATCHING PATTERN "*.h"
)
if (MSVC)
install(FILES "$<TARGET_FILE_DIR:DebugUtils>/DebugUtils-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib" OPTIONAL)
endif()

View File

@@ -1,7 +1,6 @@
file(GLOB SOURCES Source/*.cpp)
add_library(Detour ${SOURCES})
add_library(Detour)
add_library(RecastNavigation::Detour ALIAS Detour)
set_target_properties(Detour PROPERTIES
DEBUG_POSTFIX -d
SOVERSION ${SOVERSION}
@@ -24,10 +23,19 @@ endif()
target_compile_definitions(Detour PUBLIC "$<$<NOT:${RECASTNAVIGATION_ENABLE_ASSERTS}>:RC_DISABLE_ASSERTS>")
# Set include path
set(Detour_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include")
target_include_directories(Detour PUBLIC
"$<BUILD_INTERFACE:${Detour_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation>"
)
target_sources(Detour PRIVATE
Source/DetourAlloc.cpp
Source/DetourAssert.cpp
Source/DetourCommon.cpp
Source/DetourNavMesh.cpp
Source/DetourNavMeshBuilder.cpp
Source/DetourNavMeshQuery.cpp
Source/DetourNode.cpp
)
install(TARGETS Detour
@@ -38,9 +46,14 @@ install(TARGETS Detour
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
)
file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation)
install(DIRECTORY Include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
FILES_MATCHING PATTERN "*.h"
)
if(MSVC)
install(FILES "$<TARGET_FILE_DIR:Detour>/Detour-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib" OPTIONAL)
install(FILES "$<TARGET_FILE_DIR:Detour>/Detour-d.pdb"
CONFIGURATIONS "Debug"
DESTINATION "lib"
OPTIONAL)
endif()

View File

@@ -1,7 +1,6 @@
file(GLOB SOURCES Source/*.cpp)
add_library(DetourCrowd ${SOURCES})
add_library(DetourCrowd)
add_library(RecastNavigation::DetourCrowd ALIAS DetourCrowd)
set_target_properties(DetourCrowd PROPERTIES
DEBUG_POSTFIX -d
SOVERSION ${SOVERSION}
@@ -13,13 +12,20 @@ set_target_properties(DetourCrowd PROPERTIES
CXX_EXTENSIONS OFF # Disable compiler-specific extensions
)
# Set include path
set(DetourCrowd_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include")
target_include_directories(DetourCrowd PUBLIC
"$<BUILD_INTERFACE:${DetourCrowd_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation>"
)
target_sources(DetourCrowd PRIVATE
Source/DetourCrowd.cpp
Source/DetourLocalBoundary.cpp
Source/DetourObstacleAvoidance.cpp
Source/DetourPathCorridor.cpp
Source/DetourPathQueue.cpp
Source/DetourProximityGrid.cpp
)
# Set linkages
target_link_libraries(DetourCrowd Detour)
install(TARGETS DetourCrowd
@@ -30,8 +36,14 @@ install(TARGETS DetourCrowd
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
)
file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation)
install(DIRECTORY Include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
FILES_MATCHING PATTERN "*.h"
)
if(MSVC)
install(FILES "$<TARGET_FILE_DIR:DetourCrowd>/DetourCrowd-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib" OPTIONAL)
install(FILES "$<TARGET_FILE_DIR:DetourCrowd>/DetourCrowd-d.pdb"
CONFIGURATIONS "Debug"
DESTINATION "lib"
OPTIONAL)
endif()

View File

@@ -1,5 +1,4 @@
file(GLOB SOURCES Source/*.cpp)
add_library(DetourTileCache ${SOURCES})
add_library(DetourTileCache)
add_library(RecastNavigation::DetourTileCache ALIAS DetourTileCache)
set_target_properties(DetourTileCache PROPERTIES
@@ -13,13 +12,16 @@ set_target_properties(DetourTileCache PROPERTIES
CXX_EXTENSIONS OFF # Disable compiler-specific extensions
)
# Set include path
set(DetourTileCache_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include")
target_include_directories(DetourTileCache PUBLIC
"$<BUILD_INTERFACE:${DetourTileCache_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation>"
)
target_sources(DetourTileCache PRIVATE
Source/DetourTileCache.cpp
Source/DetourTileCacheBuilder.cpp
)
# Set linkages
target_link_libraries(DetourTileCache Detour)
install(TARGETS DetourTileCache
@@ -30,8 +32,11 @@ install(TARGETS DetourTileCache
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
)
file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation)
install(DIRECTORY Include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
FILES_MATCHING PATTERN "*.h"
)
if (MSVC)
install(FILES "$<TARGET_FILE_DIR:DetourTileCache>/DetourTileCache-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib" OPTIONAL)
endif()

View File

@@ -1,5 +1,5 @@
file(GLOB SOURCES Source/*.cpp)
add_library(Recast ${SOURCES})
add_library(Recast)
add_library(RecastNavigation::Recast ALIAS Recast)
set_target_properties(Recast PROPERTIES
@@ -13,13 +13,26 @@ set_target_properties(Recast PROPERTIES
CXX_EXTENSIONS OFF # Disable compiler-specific extensions
)
# Set include path
set(Recast_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include")
target_compile_definitions(Recast PUBLIC "$<$<NOT:${RECASTNAVIGATION_ENABLE_ASSERTS}>:RC_DISABLE_ASSERTS>")
target_include_directories(Recast PUBLIC
"$<BUILD_INTERFACE:${Recast_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation>"
)
target_compile_definitions(Recast PUBLIC "$<$<NOT:${RECASTNAVIGATION_ENABLE_ASSERTS}>:RC_DISABLE_ASSERTS>")
target_sources(Recast PRIVATE
Source/Recast.cpp
Source/RecastAlloc.cpp
Source/RecastArea.cpp
Source/RecastAssert.cpp
Source/RecastContour.cpp
Source/RecastFilter.cpp
Source/RecastLayers.cpp
Source/RecastMesh.cpp
Source/RecastMeshDetail.cpp
Source/RecastRasterization.cpp
Source/RecastRegion.cpp
)
install(TARGETS Recast
EXPORT recastnavigation-targets
@@ -29,8 +42,14 @@ install(TARGETS Recast
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
)
file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation)
install(DIRECTORY Include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation
FILES_MATCHING PATTERN "*.h"
)
if(MSVC)
install(FILES "$<TARGET_FILE_DIR:Recast>/Recast-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib" OPTIONAL)
install(FILES "$<TARGET_FILE_DIR:Recast>/Recast-d.pdb"
CONFIGURATIONS "Debug"
DESTINATION "lib"
OPTIONAL)
endif()

View File

@@ -1,14 +1,4 @@
include_directories(../Detour/Include)
include_directories(../Recast/Include)
add_executable(Tests
Detour/Tests_Detour.cpp
Recast/Bench_rcVector.cpp
Recast/Tests_Alloc.cpp
Recast/Tests_Recast.cpp
Recast/Tests_RecastFilter.cpp
DetourCrowd/Tests_DetourPathCorridor.cpp
)
add_executable(Tests)
set_target_properties(Tests PROPERTIES
CXX_STANDARD 20
@@ -16,18 +6,24 @@ set_target_properties(Tests PROPERTIES
CXX_EXTENSIONS OFF # Disable compiler-specific extensions
)
# Remove warnings-as-errors for third-party code
# Remove warnings-as-errors
if(MSVC)
target_compile_options(Tests PRIVATE /W3 /WX-)
else()
target_compile_options(Tests PRIVATE -Wno-error)
endif()
add_dependencies(Tests Recast Detour DetourCrowd)
target_link_libraries(Tests Recast Detour DetourCrowd)
target_include_directories(Tests PRIVATE ./Contrib)
# Use bundled catch2 rather than a possibly incompatible version installed elsewhere.
include_directories(./Contrib)
target_sources(Tests PRIVATE Contrib/catch2/catch_amalgamated.cpp)
target_sources(Tests PRIVATE
Contrib/catch2/catch_amalgamated.cpp
Detour/Tests_Detour.cpp
DetourCrowd/Tests_DetourPathCorridor.cpp
Recast/Tests_Alloc.cpp
Recast/Tests_Recast.cpp
Recast/Tests_RecastFilter.cpp
)
add_test(Tests Tests)
target_link_libraries(Tests PRIVATE Recast Detour DetourCrowd)
add_test(NAME Tests COMMAND Tests)