Skip to content

Commit

Permalink
🔧 Update conan generator to CMakeToolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherFoxGuy committed Feb 12, 2023
1 parent c41fe72 commit d1e9691
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 427 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/build-game.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Cache conan
uses: actions/cache@v3.2.4
with:
key: conan-win-${{ hashFiles('cmake/DependenciesConfig.cmake') }}
key: conan-win-${{ hashFiles('conanfile.txt') }}
path: ~/.conan/

- name: Install dependencies
Expand All @@ -30,8 +30,10 @@ jobs:

- name: Build
run: |
conan config set general.revisions_enabled=1
conan config set storage.download_cache="$env:TMP"
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release
conan install . -b missing -pr:b=tools/conan-profiles/vs-22-release-ninja -pr=tools/conan-profiles/vs-22-release-ninja
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"
ninja
- name: Test
Expand Down Expand Up @@ -63,7 +65,7 @@ jobs:
- name: Cache conan
uses: actions/cache@v3.2.4
with:
key: conan-linux-${{ hashFiles('cmake/DependenciesConfig.cmake') }}
key: conan-linux-${{ hashFiles('conanfile.txt') }}
path: ~/.conan/

- name: Install dependencies
Expand Down Expand Up @@ -109,7 +111,14 @@ jobs:
- name: Configure
run: |
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release -DCYTOPIA_USE_ANGELSCRIPT=CONAN
conan config set general.revisions_enabled=1
echo "tools.system.package_manager:mode = install" > ~/.conan/global.conf
echo "tools.system.package_manager:sudo = True" >> ~/.conan/global.conf
conan profile new --detect --force default
conan profile update conf.tools.cmake.cmaketoolchain:generator="Ninja" default
conan profile update settings.compiler.libcxx=libstdc++11 default
conan install . -s build_type=Release -b missing -pr:b=default
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"
- name: Build
run: |
Expand Down Expand Up @@ -144,15 +153,19 @@ jobs:
- name: Cache conan
uses: actions/cache@v3.2.4
with:
key: conan-mac-${{ hashFiles('cmake/DependenciesConfig.cmake') }}
key: conan-mac-${{ hashFiles('conanfile.txt') }}
path: ~/.conan/

- name: Install dependencies
run: brew install conan ninja

- name: Build
run: |
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release -DCYTOPIA_USE_ANGELSCRIPT=CONAN
conan config set general.revisions_enabled=1
conan profile new --detect --force default
conan profile update conf.tools.cmake.cmaketoolchain:generator="Ninja" default
conan install . -s build_type=Release -b missing -pr:b=default
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"
ninja
mkdir -p bin/Cytopia.App/Resources/resources
cp -pR data/resources bin/Cytopia.App/Contents/Resources/
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Cache conan
uses: actions/cache@v3.2.4
with:
key: conan-linux-${{ hashFiles('cmake/DependenciesConfig.cmake') }}
key: conan-linux-${{ hashFiles('conanfile.txt') }}
path: ~/.conan/

- name: Install dependencies
Expand Down Expand Up @@ -90,7 +90,14 @@ jobs:
- name: Configure
run: |
cmake . -DCMAKE_BUILD_TYPE=Release -DCYTOPIA_LIB_PREFERENCE=CONAN -DCYTOPIA_USE_MICROPROFILE=CONAN -DCYTOPIA_USE_ANGELSCRIPT=CONAN -DBUILD_TEST=ON -DENABLE_COVERAGE=ON
conan config set general.revisions_enabled=1
echo "tools.system.package_manager:mode = install" > ~/.conan/global.conf
echo "tools.system.package_manager:sudo = True" >> ~/.conan/global.conf
conan profile new --detect --force default
conan profile update conf.tools.cmake.cmaketoolchain:generator="Ninja" default
conan profile update settings.compiler.libcxx=libstdc++11 default
conan install . -s build_type=Release -b missing -pr:b=default
cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_TEST=ON -DENABLE_COVERAGE=ON -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"
- name: Run build-wrapper
run: build-wrapper-linux-x86-64 --out-dir bw-output make -j4
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ TileDataEditor

# ignore macOS stuff.
.DS_Store

_pmm
conanfile\.txt
Doxygen_Docs/*

*.mo

tools/l10n/TMP

#ignore redist directory
Expand All @@ -50,6 +46,5 @@ src/cmake_install.cmake
src/Makefile

tools/l10n/TMP.pot

_build/
/build*/
34 changes: 7 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/cmake/find-modules")

cmake_policy(SET CMP0127 OLD)

include(CMakeDependentOption)
include(Macros)
include(FeatureSummary)
include(SourceFileUtils)
include(CMakeCM)
set(_PREFIX "CYTOPIA_")

set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" CACHE STRING "Configuration types")

# Test if conan is installed
find_program(CONAN_CMD_TEST conan NO_CACHE)
cmake_dependent_option(USE_PACKAGE_MANAGER "Use conan" ON "NOT CONAN_CMD_TEST STREQUAL CONAN_CMD_TEST-NOTFOUND" OFF)
message(STATUS "Using conan: ${USE_PACKAGE_MANAGER}")

# create the cmake project
project(
Expand All @@ -29,17 +24,6 @@ project(

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Allow user to globally set the library preference for external libraries
cmd_option(
${_PREFIX}LIB_PREFERENCE
"Library preference [SYSTEM (if available), CONAN]"
"CONAN"
STRINGS "SYSTEM" "CONAN"
)

# Special mode, that will force dependencies to the packages provided by system unless they were set to conan explicitly.
option(${_PREFIX}FORCE_SYSTEM_DEPENDENCIES "Force the use of system packages")

option(BUILD_TEST "Build Cytopia Tests" ON)
option(ENABLE_PHC "Use a Precompiled header for speeding up the build" ON)
option(ENABLE_DEBUG "Enable Debug (asserts and logs)" OFF)
Expand Down Expand Up @@ -73,14 +57,7 @@ endif ()
################################################################################
# Check for dependencies
################################################################################

if (ANDROID)
message(STATUS "Crossbuilding to Android")
else ()
include(DependenciesConfig)
resolve_conan_dependencies()
endif ()

include(DependenciesConfig)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
link_libraries(dbghelp.lib)
Expand Down Expand Up @@ -156,3 +133,6 @@ if (WIN32)
)
endif ()
endif ()


feature_summary(WHAT ALL)
86 changes: 13 additions & 73 deletions cmake/DependenciesConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,77 +1,17 @@
include(DependenciesFunctions)
find_package(Threads REQUIRED)

add_external_lib(
SDL2
sdl/2.26.0
REQUIRED
INTERFACE_NAME SDL::SDL
PKG_CONFIG "sdl2 >= 2.0"
)
add_external_lib(
SDL2_image
sdl_image/2.0.5
REQUIRED
INTERFACE_NAME SDL::SDL_image
PKG_CONFIG "SDL2_image"
)
add_external_lib(
SDL2_ttf
sdl_ttf/2.0.18
REQUIRED
INTERFACE_NAME SDL::TTF
PKG_CONFIG "SDL2_ttf"
)

add_external_lib(
ZLIB
zlib/1.2.13
REQUIRED
PKG_CONFIG "zlib"
)
add_external_lib(
LibNoise
libnoise/1.0.0
REQUIRED
FIND_PACKAGE
)
add_external_lib(
LIBPNG
libpng/1.6.39
REQUIRED
PKG_CONFIG "libpng"
)

add_external_lib(
OpenAL
openal/1.22.2
PKG_CONFIG "openal >= 1.18"
FIND_PACKAGE_OPTIONS CONFIG
)
find_package(Threads REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(LibNoise REQUIRED)
find_package(PNG REQUIRED)

add_external_lib(
VorbisFile
vorbis/1.3.7
PKG_CONFIG "vorbis >= 1.2, vorbisfile >= 1.2"
FIND_PACKAGE
)
find_package(OpenAL CONFIG)
find_package(Vorbis)
cmake_dependent_option(ENABLE_AUDIO "use OPENAL" ON "OPENAL_FOUND AND VORBISFILE_FOUND" OFF)

add_external_lib(
Angelscript
angelscript/2.35.1
FIND_PACKAGE
BY_DEFAULT_DISABLED
)
add_external_lib(
Microprofile
microprofile/3.1
FIND_PACKAGE
BY_DEFAULT_DISABLED
)
find_package(Angelscript)
cmake_dependent_option(USE_ANGELSCRIPT "use Angelscript" ON "TARGET Angelscript::angelscript" OFF)

if (UNIX AND NOT APPLE)
add_external_lib(
libalsa
libalsa/1.2.7.2
)
endif ()
find_package(microprofile)
option(USE_MICROPROFILE "use Microprofile" OFF)
Loading

0 comments on commit d1e9691

Please sign in to comment.