diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index eb45d56..955b21f 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -46,6 +46,33 @@ jobs: working-directory: RecastDemo/Build/xcode4/ run: xcodebuild -scheme Tests -configuration ${{matrix.conf}} -project Tests.xcodeproj build + macos-cmake: + strategy: + matrix: + conf: + - Debug + - Release + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + - name: Download & install SDL + run: | + curl -L -o SDL2.dmg https://github.com/libsdl-org/SDL/releases/download/release-2.24.2/SDL2-2.24.2.dmg + hdiutil attach SDL2.dmg + cp -r /Volumes/SDL2/SDL2.framework ${{github.workspace}}/RecastDemo/Bin/ + hdiutil detach /Volumes/SDL2 + rm SDL2.dmg + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.conf}} -DSDL2_LIBRARY=${{github.workspace}}/RecastDemo/Bin/SDL2.framework + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{matrix.conf}} + linux-premake: strategy: matrix: diff --git a/.gitignore b/.gitignore index 1e20e60..ccd8a58 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,9 @@ RecastDemo/Contrib/SDL/* ## Generated doc files Docs/html +## CMake build cache +build + ## IDE files .idea/ cmake-build-*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a3fe28d..d6fc216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ SET(SOVERSION 1) set(LIB_VERSION 1.5.1) string(REPLACE "." "," LIB_VERSION_NUM "${LIB_VERSION}.0") +set_property(GLOBAL PROPERTY CXX_STANDARD 98) + option(RECASTNAVIGATION_DEMO "Build demo" ON) option(RECASTNAVIGATION_TESTS "Build tests" ON) option(RECASTNAVIGATION_EXAMPLES "Build examples" ON) diff --git a/RecastDemo/CMakeLists.txt b/RecastDemo/CMakeLists.txt index b379b27..1e8f939 100644 --- a/RecastDemo/CMakeLists.txt +++ b/RecastDemo/CMakeLists.txt @@ -3,11 +3,22 @@ file(GLOB SOURCES Source/*.cpp Contrib/fastlz/fastlz.c) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) if(NOT SDL2_ROOT_DIR) + if(WIN32) set(SDL2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Contrib/SDL") + elseif(APPLE) + set(SDL2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Bin") + endif() endif() find_package(OpenGL REQUIRED) -find_package(SDL2 REQUIRED) +if(APPLE) + find_library(SDL2_LIBRARY + NAMES SDL2 + PATHS ${SDL2_ROOT_DIR} + REQUIRED) +else() + find_package(SDL2 REQUIRED) +endif() include_directories(SYSTEM ${OPENGL_INCLUDE_DIR}) include_directories(SYSTEM Contrib/fastlz) @@ -19,6 +30,9 @@ include_directories(../DetourTileCache/Include) include_directories(../Recast/Include) include_directories(Include) include_directories(Contrib/SDL/include) +if(APPLE) + include_directories(${SDL2_LIBRARY}/Headers) +endif() if (WIN32) add_executable(RecastDemo WIN32 ${SOURCES}) @@ -54,7 +68,12 @@ endif() add_dependencies(RecastDemo DebugUtils Detour DetourCrowd DetourTileCache Recast) -target_link_libraries(RecastDemo ${OPENGL_LIBRARIES} SDL2::SDL2main DebugUtils Detour DetourCrowd DetourTileCache Recast) +if(APPLE) + target_link_libraries(RecastDemo ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} DebugUtils Detour DetourCrowd DetourTileCache Recast) +else() + target_link_libraries(RecastDemo ${OPENGL_LIBRARIES} SDL2::SDL2main DebugUtils Detour DetourCrowd DetourTileCache Recast) +endif() + install(TARGETS RecastDemo RUNTIME DESTINATION bin diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 3b90689..45d7d1f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -6,6 +6,9 @@ include_directories(./Contrib/Catch) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_executable(Tests ${TESTS_SOURCES}) + +set_property(TARGET Tests PROPERTY CXX_STANDARD 17) + add_dependencies(Tests Recast Detour) target_link_libraries(Tests Recast Detour) add_test(Tests Tests)