Skip to content

Commit

Permalink
Support build by CMake (recastnavigation#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsid authored and jakobbotsch committed Apr 20, 2018
1 parent 05dd77d commit 4566d01
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ RecastDemo/Contrib/SDL/*

## Generated doc files
Docs/html

## IDE files
.idea/
cmake-build-*/
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ compiler:

# Build both debug and release configurations, through use of an environment variable in the build matrix.
env:
- CONFIGURATION=debug
- CONFIGURATION=release
- CONFIGURATION: debug
CMAKE_BUILD_TYPE: Debug
- CONFIGURATION: release
CMAKE_BUILD_TYPE: Release

install:
# Download and build SDL2 from source.
Expand All @@ -23,7 +25,7 @@ install:
- tar -xzf SDL2.tar.gz
- cd SDL2-2.0.4
- ./configure --prefix=$PREFIX
- make -j5
- make -j$(nproc)
- make install
- cd ..
# Download and build premake5 from source; the Travis environment doesn't have the right version of glibc6 for the prebuilt binaries to work.
Expand All @@ -38,8 +40,11 @@ install:
# Have to cd into directory and back out since premake5 doesn't appear to accept a directory argument.
before_script:
- cd RecastDemo && ../premake5 gmake && cd ..
- mkdir build && cd build && cmake -DRECASTNAVIGATION_STATIC=TRUE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .. && cd ..

# Run make in the directory containing generated makefiles, on the configuration specified by the environment variable.
script:
- make -C RecastDemo/Build/gmake config=$CONFIGURATION
- make -C RecastDemo/Build/gmake -j$(nproc) config=$CONFIGURATION
- RecastDemo/Bin/Tests
- make -C build -j$(nproc)
- cd build && ctest
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.0)

project(RecastNavigation)

# lib versions
SET(SOVERSION 1)
SET(VERSION 1.0.0)

option(RECASTNAVIGATION_DEMO "Build demo" ON)
option(RECASTNAVIGATION_TESTS "Build tests" ON)
option(RECASTNAVIGATION_EXAMPLES "Build examples" ON)
option(RECASTNAVIGATION_STATIC "Build static libraries" OFF)

add_subdirectory(DebugUtils)
add_subdirectory(Detour)
add_subdirectory(DetourCrowd)
add_subdirectory(DetourTileCache)
add_subdirectory(Recast)

if (RECASTNAVIGATION_DEMO)
add_subdirectory(RecastDemo)
endif ()

if (RECASTNAVIGATION_TESTS)
enable_testing()
add_subdirectory(Tests)
endif ()
26 changes: 26 additions & 0 deletions DebugUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
file(GLOB SOURCES Source/*.cpp)

include_directories(../Recast/Include)
include_directories(../Detour/Include)
include_directories(../DetourTileCache/Include)
include_directories(Include)

if (RECASTNAVIGATION_STATIC)
add_library(DebugUtils STATIC ${SOURCES})
else()
add_library(DebugUtils SHARED ${SOURCES})
endif()

set_target_properties(DebugUtils PROPERTIES
SOVERSION ${SOVERSION}
VERSION ${VERSION}
)

install(TARGETS DebugUtils
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library
)

file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION include)
23 changes: 23 additions & 0 deletions Detour/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file(GLOB SOURCES Source/*.cpp)

include_directories(Include)

if(RECASTNAVIGATION_STATIC)
add_library(Detour STATIC ${SOURCES})
else()
add_library(Detour SHARED ${SOURCES})
endif()

set_target_properties(Detour PROPERTIES
SOVERSION ${SOVERSION}
VERSION ${VERSION}
)

install(TARGETS Detour
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library
)

file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION include)
24 changes: 24 additions & 0 deletions DetourCrowd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
file(GLOB SOURCES Source/*.cpp)

include_directories(../Detour/Include)
include_directories(Include)

if (RECASTNAVIGATION_STATIC)
add_library(DetourCrowd STATIC ${SOURCES})
else ()
add_library(DetourCrowd SHARED ${SOURCES})
endif ()

set_target_properties(DetourCrowd PROPERTIES
SOVERSION ${SOVERSION}
VERSION ${VERSION}
)

install(TARGETS DetourCrowd
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library
)

file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION include)
25 changes: 25 additions & 0 deletions DetourTileCache/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
file(GLOB SOURCES Source/*.cpp)

include_directories(../Detour/Include)
include_directories(Include)

if (RECASTNAVIGATION_STATIC)
add_library(DetourTileCache STATIC ${SOURCES})
else ()
add_library(DetourTileCache SHARED ${SOURCES})
endif ()

set_target_properties(DetourTileCache PROPERTIES
SOVERSION ${SOVERSION}
VERSION ${VERSION}
)


install(TARGETS DetourTileCache
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library
)

file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION include)
23 changes: 23 additions & 0 deletions Recast/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file(GLOB SOURCES Source/*.cpp)

include_directories(Include)

if (RECASTNAVIGATION_STATIC)
add_library(Recast STATIC ${SOURCES})
else ()
add_library(Recast SHARED ${SOURCES})
endif ()

set_target_properties(Recast PROPERTIES
SOVERSION ${SOVERSION}
VERSION ${VERSION}
)

install(TARGETS Recast
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
COMPONENT library
)

file(GLOB INCLUDES Include/*.h)
install(FILES ${INCLUDES} DESTINATION include)
27 changes: 27 additions & 0 deletions RecastDemo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
file(GLOB SOURCES Source/*.cpp Contrib/fastlz/fastlz.c)

include(cmake/FindSDL2.cmake)

find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)

include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM ${SDL2_INCLUDE_DIRS})
include_directories(SYSTEM Contrib/fastlz)
include_directories(SYSTEM Contrib)
include_directories(../DebugUtils/Include)
include_directories(../Detour/Include)
include_directories(../DetourCrowd/Include)
include_directories(../DetourTileCache/Include)
include_directories(../Recast/Include)
include_directories(Include)

add_executable(RecastDemo ${SOURCES})
file(COPY Bin/Meshes DESTINATION ${CMAKE_BINARY_DIR}/RecastDemo)
file(COPY Bin/TestCases DESTINATION ${CMAKE_BINARY_DIR}/RecastDemo)
file(COPY Bin/DroidSans.ttf DESTINATION ${CMAKE_BINARY_DIR}/RecastDemo)

add_dependencies(RecastDemo DebugUtils Detour DetourCrowd DetourTileCache Recast)
target_link_libraries(RecastDemo ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} DebugUtils Detour DetourCrowd DetourTileCache Recast)

install(TARGETS RecastDemo RUNTIME DESTINATION bin)
Loading

0 comments on commit 4566d01

Please sign in to comment.