$NetBSD: patch-CMakeLists.txt,v 1.7 2025/08/25 18:14:39 pho Exp $ Do not insist on old cmake policies (allows build with cmake 4). Get X265_VERSION and X265_LATEST_TAG from outside. Solaris ld: Provided assembler is not PIC, so we pass "-mimpure-text" to the compiler so it doesn't send "-ztext" to ld. Solaris ld: Passing "-Wa,--noexecstack" to gcc will generate an ELF section requesting a non executable stack. I don't know if Solaris ld is complying or just ignoring it. --- CMakeLists.txt.orig 2024-11-22 12:07:34.000000000 +0000 +++ CMakeLists.txt @@ -6,15 +6,9 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) endif() message(STATUS "cmake version ${CMAKE_VERSION}") -if(POLICY CMP0025) - cmake_policy(SET CMP0025 OLD) # report Apple's Clang as just Clang -endif() if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH endif() -if(POLICY CMP0054) - cmake_policy(SET CMP0054 OLD) # Only interpret if() arguments as variables or keywords when unquoted -endif() project (x265) cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8 @@ -168,7 +162,7 @@ if(APPLE) add_definitions(-DMACOS=1) endif() -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") +if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang|AppleClang") set(CLANG 1) endif() if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") @@ -207,6 +201,11 @@ if(HAVE_INT_TYPES_H) add_definitions(-DHAVE_INT_TYPES_H=1) endif() +check_include_files(alloca.h HAVE_ALLOCA_H) +if(HAVE_ALLOCA_H) + add_definitions(-DHAVE_ALLOCA_H=1) +endif() + if(INTEL_CXX AND UNIX) set(GCC 1) # treat icpc roughly like gcc elseif(CLANG) @@ -614,7 +613,7 @@ endif(ARM64) option(WARNINGS_AS_ERRORS "Stop compiles on first warning" OFF) if(WARNINGS_AS_ERRORS) - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") add_definitions(-Werror) add_definitions(-Wno-unused) elseif(MSVC) @@ -658,7 +657,6 @@ if(POWER) endif() endif() -include(Version) # determine X265_VERSION and X265_LATEST_TAG include_directories(. common encoder "${PROJECT_BINARY_DIR}") option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF) @@ -906,7 +904,11 @@ if(ENABLE_SHARED) elseif(CYGWIN) # Cygwin is not officially supported or tested. MinGW with msys is recommended. else() - list(APPEND LINKER_OPTIONS "-Wl,-Bsymbolic,-znoexecstack") + if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + list(APPEND LINKER_OPTIONS "-mimpure-text -Wa,--noexecstack") + else() + list(APPEND LINKER_OPTIONS "-Wl,-Bsymbolic,-znoexecstack") + endif() endif() endif() set_target_properties(x265-shared PROPERTIES SOVERSION ${X265_BUILD})