Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 5 additions & 99 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,6 @@ project(libuhdr
LANGUAGES C CXX
DESCRIPTION "Library for encoding and decoding ultrahdr images")

###########################################################
# Detect system
###########################################################
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
elseif(WIN32)
elseif(APPLE)
else()
message(FATAL_ERROR "Platform ${CMAKE_SYSTEM_NAME} not recognized")
endif()

if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "amd64")
else()
set(ARCH "i386")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*")
set(ARCH "i386")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "aarch64")
else()
set(ARCH "arm")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARCH "arm")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64")
set(ARCH "riscv64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv32")
set(ARCH "riscv32")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
set(ARCH "loong64")
else()
message(FATAL_ERROR "Architecture: ${CMAKE_SYSTEM_PROCESSOR} not recognized")
endif()

# Cross compiling on macOS. The cross compiling architecture should override
# auto-detected system architecture settings.
if(CMAKE_OSX_ARCHITECTURES)
if(APPLE)
if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(ARCH "aarch64")
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
set(ARCH "x86_64")
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "i386")
set(ARCH "x86")
else()
message(FATAL_ERROR "Architecture ${CMAKE_OSX_ARCHITECTURES} is not "
"supported. Only one architecture (arm64, x86_64 "
"or i386) could be specified at build time.")
endif()
else()
message(WARNING "ignoring setting CMAKE_OSX_ARCHITECTURES:= ${CMAKE_OSX_ARCHITECTURES}")
endif()
endif()

###########################################################
# Directories
###########################################################
Expand Down Expand Up @@ -287,45 +228,9 @@ elseif(EMSCRIPTEN)
or try 'cmake -DUHDR_BUILD_DEPS=1'")
endif()
endif()
else()
add_compile_options(-ffunction-sections)
add_compile_options(-fdata-sections)
add_compile_options(-fomit-frame-pointer)
add_compile_options(-ffp-contract=fast)
if(ARCH STREQUAL "i386")
add_compile_options(-m32)
add_compile_options(-march=i386)
add_compile_options(-mtune=generic)
elseif(ARCH STREQUAL "amd64")
add_compile_options(-m64)
add_compile_options(-march=x86-64)
add_compile_options(-mtune=generic)
elseif(ARCH STREQUAL "arm")
add_compile_options(-march=armv7-a)
add_compile_options(-marm)
if(NOT ANDROID_ABI)
add_compile_options(-mfloat-abi=hard)
endif()
add_compile_options(-mfpu=neon-vfpv3)
add_compile_options(-fno-lax-vector-conversions)
elseif(ARCH STREQUAL "aarch64")
add_compile_options(-march=armv8-a)
add_compile_options(-fno-lax-vector-conversions)
elseif(ARCH STREQUAL "riscv64")
add_compile_options(-march=rv64gc)
add_compile_options(-mabi=lp64d)
elseif(ARCH STREQUAL "riscv32")
add_compile_options(-march=rv32gc)
add_compile_options(-mabi=ilp32d)
elseif(ARCH STREQUAL "loong64")
add_compile_options(-march=loongarch64)
add_compile_options(-mabi=lp64d)
endif()

if(UHDR_ENABLE_WERROR)
CheckCompilerOption("-Werror" SUPPORTS_WERROR)
set(UHDR_WERROR_FLAGS "-Werror")
endif()
elseif(UHDR_ENABLE_WERROR)
CheckCompilerOption("-Werror" SUPPORTS_WERROR)
set(UHDR_WERROR_FLAGS "-Werror")
endif()

###########################################################
Expand Down Expand Up @@ -585,7 +490,8 @@ set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
###########################################################
file(GLOB UHDR_CORE_SRCS_LIST "${SOURCE_DIR}/src/*.cpp")
if(UHDR_ENABLE_INTRINSICS)
if(ARCH STREQUAL "arm" OR ARCH STREQUAL "aarch64")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC)
if(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm")
file(GLOB UHDR_CORE_NEON_SRCS_LIST "${SOURCE_DIR}/src/dsp/arm/*.cpp")
list(APPEND UHDR_CORE_SRCS_LIST ${UHDR_CORE_NEON_SRCS_LIST})
endif()
Expand Down
3 changes: 0 additions & 3 deletions cmake/package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "")
message(FATAL_ERROR "Failed to determine CPACK_SYSTEM_NAME. Is CMAKE_SYSTEM_NAME set?" )
endif()
string(TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
set(CPACK_PACKAGE_ARCHITECTURE ${ARCH})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_ARCHITECTURE}")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})

Expand All @@ -46,7 +44,6 @@ elseif(UNIX)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL})
elseif(EXISTS "/etc/redhat-release")
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE})
set(CPACK_RPM_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
set(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_HOMEPAGE_URL})
Expand Down