Skip to content

Commit

Permalink
Use conan2
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Sep 9, 2023
1 parent 0a1672e commit 07fa8f1
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 378 deletions.
30 changes: 12 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,21 @@ jobs:
matrix:
include:
- os: windows-2019
arch: x64
submodules_mode: true
cibw_archs_windows: AMD64
cibw_environment: APNGASM_COMPILE_TARGET=x64
cibw_environment: APNGASM_COMPILE_TARGET=x86_64
cibw_before_all: prepare-win.bat
- os: windows-2019
arch: x86
submodules_mode: true
cibw_archs_windows: x86
cibw_environment: APNGASM_COMPILE_TARGET=x86
cibw_before_all: prepare-win.bat
- os: windows-2019
arch: arm64
submodules_mode: true
cibw_archs_windows: ARM64
cibw_environment: APNGASM_COMPILE_TARGET=ARM64
cibw_environment: APNGASM_COMPILE_TARGET=armv8
cibw_before_all: prepare-win.bat
- os: macos-11
arch: x64
submodules_mode: true
cibw_archs_macos: x86_64
cibw_environment: >
Expand All @@ -48,11 +44,10 @@ jobs:
VCPKG_CXX_FLAGS="-mmacosx-version-min=10.15"
cibw_before_all: ./prepare-mac.sh
- os: macos-11
arch: arm64
submodules_mode: true
cibw_archs_macos: arm64
cibw_environment: >
APNGASM_COMPILE_TARGET=arm64
APNGASM_COMPILE_TARGET=armv8
_PYTHON_HOST_PLATFORM=macosx-11.0-arm64
VCPKG_OSX_DEPLOYMENT_TARGET=11.0
MACOSX_DEPLOYMENT_TARGET=11.0
Expand All @@ -61,7 +56,6 @@ jobs:
VCPKG_CXX_FLAGS="-mmacosx-version-min=11.0"
cibw_before_all: ./prepare-mac.sh
- os: macos-11
arch: universal2
submodules_mode: true
cibw_archs_macos: universal2
cibw_environment: >
Expand All @@ -73,57 +67,57 @@ jobs:
VCPKG_C_FLAGS="-mmacosx-version-min=11.0"
VCPKG_CXX_FLAGS="-mmacosx-version-min=11.0"
- os: ubuntu-20.04
arch: x64
submodules_mode: true
cibw_archs_linux: x86_64
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=x86_64
- os: ubuntu-20.04
arch: x86
submodules_mode: true
cibw_archs_linux: i686
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=x86
- os: ubuntu-20.04
arch: arm64
submodules_mode: true
cibw_archs_linux: aarch64
cibw_skip: "*-muslinux_* pp*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=armv8
- os: ubuntu-20.04
arch: arm64
submodules_mode: true
cibw_archs_linux: aarch64
cibw_skip: "*-multilinux_* pp*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=armv8
- os: ubuntu-20.04
arch: arm64
submodules_mode: true
cibw_archs_linux: aarch64
cibw_skip: "*-muslinux_* *-multilinux_*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=armv8
- os: ubuntu-20.04
arch: ppc64le
submodules_mode: true
cibw_archs_linux: ppc64le
cibw_skip: "*-muslinux_*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=ppc64le
- os: ubuntu-20.04
arch: ppc64le
submodules_mode: true
cibw_archs_linux: ppc64le
cibw_skip: "*-multilinux_*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=ppc64le
- os: ubuntu-20.04
arch: s390x
submodules_mode: true
cibw_archs_linux: s390x
cibw_skip: "*-muslinux_*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=s390x
- os: ubuntu-20.04
arch: s390x
submodules_mode: true
cibw_archs_linux: s390x
cibw_skip: "*-multilinux_*"
cibw_before_all: ./prepare-linux.sh
cibw_environment: APNGASM_COMPILE_TARGET=s390x

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
dist/
.py-build-cmake_cache/
fakeroot/
.vscode/
.vscode/
conan_output/
106 changes: 11 additions & 95 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,104 +11,28 @@ elseif (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
endif()

if (WIN32)
set(GET_TARGET_CMD "cmd" "/c" "${CMAKE_SOURCE_DIR}/get-target-win.bat")
set(PREPARE_CMD "cmd" "/c" "${CMAKE_SOURCE_DIR}/prepare-win.bat")
elseif (APPLE)
set(GET_TARGET_CMD "${CMAKE_SOURCE_DIR}/get-target-mac.sh")
set(PREPARE_CMD "${CMAKE_SOURCE_DIR}/prepare-mac.sh")
else()
set(GET_TARGET_CMD "${CMAKE_SOURCE_DIR}/get-target-linux.sh")
set(PREPARE_CMD "${CMAKE_SOURCE_DIR}/prepare-linux.sh")
endif()
find_package(PythonInterp 3 REQUIRED)

set(PREPARE_CMD ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/get-deps.py")

message(STATUS "Executing get-deps.py")
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${PREPARE_CMD}
OUTPUT_VARIABLE APNGASM_COMPILE_TARGET
)
message(STATUS "Finished get-deps.py")
message(STATUS "APNGASM_COMPILE_TARGET is ${APNGASM_COMPILE_TARGET}")

set(ZLIB_USE_STATIC_LIBS ON)
set(PNG_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_LIBS ON)
if (WIN32)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
set(STATIC_LIBRARY_SUFFIX ".lib")
else()
set(STATIC_LIBRARY_SUFFIX ".a")
endif()

if (DEFINED ENV{VCPKG_INSTALLATION_ROOT})
set(VCPKG_INSTALLATION_ROOT $ENV{VCPKG_INSTALLATION_ROOT})
endif()

if (DEFINED VCPKG_INSTALLATION_ROOT)
if (DEFINED ENV{APNGASM_COMPILE_TARGET})
set(APNGASM_COMPILE_TARGET $ENV{APNGASM_COMPILE_TARGET})
elseif (NOT DEFINED APNGASM_COMPILE_TARGET)
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GET_TARGET_CMD}
OUTPUT_VARIABLE APNGASM_COMPILE_TARGET
)
if (DEFINED ENV{APNGASM_COMPILE_TARGET})
set(APNGASM_COMPILE_TARGET $ENV{APNGASM_COMPILE_TARGET})
endif()
endif()

if (DEFINED ENV{PLATFORM})
set(PLATFORM $ENV{PLATFORM})
elseif (NOT DEFINED PLATFORM)
if (WIN32)
set(PLATFORM windows-static)
elseif (APPLE)
set(PLATFORM osx)
else()
set(PLATFORM linux)
endif()
endif()

if (WIN32)
set(LIBZ_NAME zlib)
set(LIBPNG_NAME libpng16)
else()
set(LIBZ_NAME libz)
set(LIBPNG_NAME libpng16)
endif()

set(ZLIB_ROOT ${VCPKG_INSTALLATION_ROOT}/installed)
set(PNG_ROOT ${VCPKG_INSTALLATION_ROOT}/installed)
set(Boost_ROOT ${VCPKG_INSTALLATION_ROOT}/installed)

set(VCPKG_TARGET_TRIPLET ${APNGASM_COMPILE_TARGET}-${PLATFORM})

include_directories(${VCPKG_INSTALLATION_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/include)
set(LIBZ_PATH ${VCPKG_INSTALLATION_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/lib/${LIBZ_NAME}${STATIC_LIBRARY_SUFFIX})
set(LIBPNG_PATH ${VCPKG_INSTALLATION_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/lib/${LIBPNG_NAME}${STATIC_LIBRARY_SUFFIX})

set(CMAKE_TOOLCHAIN_FILE "${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
else()
if (WIN32)
set(LIBZ_NAME zlibstatic)
set(LIBPNG_NAME libpng16_static)
else()
set(LIBZ_NAME libz)
set(LIBPNG_NAME libpng16)
endif()

set(ZLIB_ROOT ${CMAKE_SOURCE_DIR}/fakeroot)
set(PNG_ROOT ${CMAKE_SOURCE_DIR}/fakeroot)
set(Boost_ROOT ${CMAKE_SOURCE_DIR}/fakeroot)

set(LIBZ_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib/${LIBZ_NAME}${STATIC_LIBRARY_SUFFIX})
if(NOT EXISTS ${LIBZ_PATH})
set(LIBZ_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib64/${LIBZ_NAME}${STATIC_LIBRARY_SUFFIX})
endif()

set(LIBPNG_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib/${LIBPNG_NAME}${STATIC_LIBRARY_SUFFIX})
if(NOT EXISTS ${LIBPNG_PATH})
set(LIBPNG_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib64/${LIBPNG_NAME}${STATIC_LIBRARY_SUFFIX})
endif()
endif()
include(${CMAKE_SOURCE_DIR}/conan_output/${APNGASM_COMPILE_TARGET}/conan_toolchain.cmake)

project(apngasm-python VERSION 1.0.6)
set(PY_VERSION_SUFFIX "")
Expand All @@ -135,22 +59,14 @@ target_compile_definitions(_apngasm_python PRIVATE _apngasm_python_EXPORTS)
target_compile_definitions(_apngasm_python PRIVATE apngasm_EXPORTS)

# Static linking
add_library(zlibstatic STATIC IMPORTED)
add_library(png_static STATIC IMPORTED)

add_subdirectory(apngasm)
set_target_properties(apngasm-static PROPERTIES BUILD_SHARED_LIBS OFF)

include_directories(${CMAKE_SOURCE_DIR}/fakeroot/include)
include_directories(${CMAKE_BINARY_DIR}/apngasm/lib/src)
include_directories(${CMAKE_SOURCE_DIR}/apngasm/lib/src)
include_directories(${CMAKE_SOURCE_DIR}/apngasm/lib/src/listener)

set_target_properties(zlibstatic PROPERTIES IMPORTED_LOCATION ${LIBZ_PATH})
set_target_properties(png_static PROPERTIES IMPORTED_LOCATION ${LIBPNG_PATH})

target_link_libraries(_apngasm_python PRIVATE apngasm-static png_static zlibstatic)

target_link_libraries(_apngasm_python PRIVATE apngasm-static)
target_compile_definitions(_apngasm_python PRIVATE
MODULE_NAME=$<TARGET_FILE_BASE_NAME:_apngasm_python>
VERSION_INFO="${PY_FULL_VERSION}"
Expand Down
9 changes: 9 additions & 0 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"/mnt/Library-SSD/Codes/apngasm-python/conan_output/x86_64/CMakePresets.json"
]
}
2 changes: 1 addition & 1 deletion apngasm
Submodule apngasm updated 1 files
+2 −2 lib/CMakeLists.txt
19 changes: 19 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from conan import ConanFile
import shutil
import platform

class ApngasmRecipe(ConanFile):
settings = 'os', 'compiler', 'build_type', 'arch'

def requirements(self):
self.requires("zlib/1.2.13")
self.requires("libpng/1.6.40")
self.requires("boost/1.83.0")
self.generators = ['CMakeToolchain', 'CMakeDeps']

def build_requirements(self):
if not shutil.which('cmake'):
self.tool_requires("cmake/[>=3.5]")

def build(self):
build_type = 'Release'
Loading

0 comments on commit 07fa8f1

Please sign in to comment.