From d302d7ebd5e32304386c6c959246dc93d7b8bf69 Mon Sep 17 00:00:00 2001 From: JackCarterSmith Date: Fri, 29 Sep 2023 15:16:29 +0200 Subject: [PATCH 1/2] Pre-migration of conan manager to v2 --- CMakeLists.txt | 5 ++--- Jenkinsfile | 8 ++++---- RSETexture/CMakeLists.txt | 12 +++++++----- cmake/mingw_cross_toolchain.cmake | 8 -------- conanfile.txt | 10 +++++----- 5 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 cmake/mingw_cross_toolchain.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 61d7efa..a9a1a34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ # CMake requirement and general configuration -cmake_minimum_required(VERSION 3.12) -cmake_policy(VERSION 3.12) +cmake_minimum_required(VERSION 3.15) +cmake_policy(VERSION 3.15) set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) if(DEFINED ENV{MS_COMPATIBLE}) set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries @@ -24,7 +24,6 @@ else() # Standalone project mode, should not be used for release. set(RSE_TEXTURE_NAME RSETexture) endif() set(RSP_TEXTURE_LIB_NAME RSPTexture${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") diff --git a/Jenkinsfile b/Jenkinsfile index 5ac09a1..45013cd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,9 +23,9 @@ pipeline { checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]]) sh 'git submodule update --init --recursive' dir("build") { - rtConanRun(clientId: "conan", command: "install .. --build=missing") + rtConanRun(clientId: "conan", command: "install .. -s build_type=Release -pr:h=default -pr:b=default --build=missing") } - cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']] + cmakeBuild buildDir: 'build', cmakeArgs: '-DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release', installation: 'latest', steps: [[args: 'all']] } }, windows: { @@ -33,9 +33,9 @@ pipeline { checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Terrain'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]]) sh 'git submodule update --init --recursive' dir("build") { - rtConanRun(clientId: "conan", command: "install .. -pr:b=default -pr:h=windows --build=missing") + rtConanRun(clientId: "conan", command: "install .. -s build_type=Release -pr:b=default -pr:h=windows --build=missing") } - cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw_cross_toolchain.cmake', installation: 'latest', steps: [[args: 'all']] + cmakeBuild buildDir: 'build', cmakeArgs: '-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release', installation: 'latest', steps: [[args: 'all']] } } ) diff --git a/RSETexture/CMakeLists.txt b/RSETexture/CMakeLists.txt index 5ff87f7..0751b68 100644 --- a/RSETexture/CMakeLists.txt +++ b/RSETexture/CMakeLists.txt @@ -12,7 +12,7 @@ include(CheckCSourceCompiles) if(BUILD_TOOLS) # Import needed packages and references their include path - find_package(PNG 1.6.37 REQUIRED) + find_package(PNG 1.6.40 REQUIRED) include_directories(${PNG_INCLUDE_DIR}) @@ -40,9 +40,11 @@ if(BUILD_TOOLS) endif() # Link externals libraries to the linker - if(RSPTEXTURE_SHARED) - target_link_libraries(rse-texture PRIVATE rsp-texture-lib ${PNG_LIBRARIES}) - elseif(RSPTEXTURE_STATIC) - target_link_libraries(rse-texture PRIVATE rsp-texture-libstatic ${PNG_LIBRARIES}) + if (TARGET PNG::PNG) + if(RSPTEXTURE_SHARED) + target_link_libraries(rse-texture PRIVATE rsp-texture-lib PNG::PNG) + elseif(RSPTEXTURE_STATIC) + target_link_libraries(rse-texture PRIVATE rsp-texture-libstatic PNG::PNG) + endif() endif() endif() diff --git a/cmake/mingw_cross_toolchain.cmake b/cmake/mingw_cross_toolchain.cmake deleted file mode 100644 index aaf5303..0000000 --- a/cmake/mingw_cross_toolchain.cmake +++ /dev/null @@ -1,8 +0,0 @@ -SET(CMAKE_SYSTEM_NAME Windows) -IF("${GNU_HOST}" STREQUAL "") - SET(GNU_HOST i586-mingw32msvc) -ENDIF() -# Prefix detection only works with compiler id "GNU" -SET(CMAKE_C_COMPILER ${GNU_HOST}-gcc) -# CMake doesn't automatically look for prefixed 'windres', do it manually: -SET(CMAKE_RC_COMPILER ${GNU_HOST}-windres) diff --git a/conanfile.txt b/conanfile.txt index ad814ca..ce07e68 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,13 +1,13 @@ [requires] -zlib/1.2.12 -libpng/1.6.37 +zlib/1.2.13 +libpng/1.6.40 [generators] -cmake -cmake_find_package +CMakeDeps +CMakeToolchain [options] -libpng:shared=True +libpng/*:shared=True [imports] bin, *.dll -> ./bin \ No newline at end of file -- 2.39.5 From 0c8282ab5d2047c47e0a7b049920b8f19ca04732 Mon Sep 17 00:00:00 2001 From: JackCarterSmith Date: Sat, 18 May 2024 20:04:58 +0200 Subject: [PATCH 2/2] Validated conan v2 migration --- .gitignore | 1 + README.md | 43 ++++++++++++------------------------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 0f2e944..13620b8 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,4 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps +CMakeUserPresets.json diff --git a/README.md b/README.md index 90d3f1b..3bc7a24 100644 --- a/README.md +++ b/README.md @@ -44,45 +44,26 @@ Due to issue with copyrights, I can't provide samples... You need to extract HMT Necessary libs (provided only in windows release) for running and for compiling. -- libpng (1.6.37) +- [zlib](https://www.zlib.net/) (1.2.13) +- [libpng](http://www.libpng.org/pub/png/libpng.html) (1.6.40) ### Compiling -You can compile on both Windows (MinGW) or native Linux system thanks to CMake, you only need to adjust your dependencies on Windows or use Conan packages manager (https://conan.io). -libpng16-dev distrib package can be used on debian/ubuntu. - -To compile, just clone and launch cmake: +I've a preference for compiling libraries by hand, mainly for backward compatibility, but I recommend using Conan packages manager (https://conan.io) for simplicity. ```shell -cmake . -make -make install -``` - -On Windows system, I can suggest you to use Conan support to help you with dependencies: - -```shell -mkdir build +conan install -of build . --build=missing -pr:b=default -pr:h=default cd build -conan install .. --build=missing -cmake .. -G "MinGW Makefiles" -make +cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" +cmake --build . ``` -If you want to do it manually without Conan support, you will probably need to specify the dependency flags for CMake. Ex: +On Windows environment, you can use MinGW `-G "MinGW Makefiles"` or Ninja `-G "Ninja"` as CMake generator. -`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.12/include" -D"ZLIB_LIBRARY=zlib/1.2.12/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" -D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" . -G "MinGW Makefiles"` +### Compiling (HARDCORE) -We can also use cross-compilation (after installing `mingw64` and `cmake` packages on your distrib): +If you want to do it manually without Conan, you will probably need to specify the dependency flags for CMake. Ex: -```shell -mkdir build && cd build -cmake -DGNU_HOST=x86_64-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake \ - -D"ZLIB_INCLUDE_DIR=zlib/1.2.12/include" \ - -D"ZLIB_LIBRARY=zlib/1.2.12/lib/libzlib.dll.a" \ - -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" \ - -D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" \ - .. -cmake --build . -``` \ No newline at end of file +`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.13/include" -D"ZLIB_LIBRARY=zlib/1.2.13/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.40/include" -D"PNG_LIBRARY=libpng/1.6.40/lib/libpng.dll.a" . -G "MinGW Makefiles"` + +I've tested cross-compilation too, but since I want to check that Conan is working properly at each release, I've integrated it into the Jenkins flow using Conan for the cross-abstraction. -- 2.39.5