Skip to content

Commit

Permalink
Revert "CMakeの新しい機能をもちいてコンパイル/リンクフラグの管理をする"
Browse files Browse the repository at this point in the history
This reverts commit 797d94c.
  • Loading branch information
tsukumijima committed Feb 13, 2024
1 parent 687cc44 commit ada8d3e
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.1)

if(CMAKE_VERSION VERSION_GREATER 3.21)
cmake_policy(SET CMP0128 NEW)
endif()
if(CMAKE_VERSION VERSION_GREATER 3.15)
cmake_policy(SET CMP0091 NEW)
endif()
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0063 NEW)
if(CMAKE_VERSION VERSION_GREATER 3.1)
cmake_policy(SET CMP0054 NEW)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE INTERNAL "limit build types" FORCE)
Expand Down Expand Up @@ -76,28 +77,37 @@ set(ARIBB25_VERSION_STRING ${ARIBB25_VERSION_NUMBER})
# ---------- define flags ----------

if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)")
set(CMAKE_C_VISIBILITY_PRESET "hidden")
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_C_FLAGS "-Wall")
set(CMAKE_C_FLAGS_DEBUG "-O2 -g")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-O3 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_SHARED_LINKER_FLAGS "-fvisibility=hidden")

if(UNIX AND NOT CYGWIN)
include(ElfInterp)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fPIC ${CMAKE_CXX_FLAGS}")
if(NOT APPLE)
add_link_options("-Wl,-eshow_version")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-eshow_version")
endif()
else(MINGW)
add_link_options("-Wl,--enable-stdcall-fixup" "-static-libgcc")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-stdcall-fixup -static-libgcc")
endif()

if(MINGW AND USE_UNICODE)
add_link_options("-municode")
set(CMAKE_C_FLAGS "-municode ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-municode ${CMAKE_CXX_FLAGS}")
endif()

if(USE_AVX2)
add_compile_options("-mavx2")
set(CMAKE_C_FLAGS "-mavx2 ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-mavx2 ${CMAKE_CXX_FLAGS}")
endif()
if(USE_NEON)
add_compile_options("-mfpu=neon")
set(CMAKE_C_FLAGS "-mfpu=neon ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-mfpu=neon ${CMAKE_CXX_FLAGS}")
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
Expand All @@ -106,7 +116,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")

if(USE_AVX2)
add_definitions("-DENABLE_MULTI2_SIMD")
add_compile_options("/arch:AVX2")
set(CMAKE_C_FLAGS "/arch:AVX2 ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "/arch:AVX2 ${CMAKE_CXX_FLAGS}")
endif()
endif()

Expand All @@ -128,9 +139,9 @@ link_directories(${PCSC_LIBRARY_DIRS})
# ---------- libaribb1 ----------

if(WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "(ARM|ARM64|AARCH64)")
add_library(aribb1-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.c aribb25/multi2_simd.c aribb25/ts_section_parser.c aribb25/version_b1.c)
add_library(aribb1-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.c aribb25/multi2_simd.c aribb25/ts_section_parser.c aribb25/version_b1.c)
else()
add_library(aribb1-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.cc aribb25/ts_section_parser.c aribb25/version_b1.c)
add_library(aribb1-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.cc aribb25/ts_section_parser.c aribb25/version_b1.c)
endif()
set_target_properties(aribb1-objlib PROPERTIES COMPILE_DEFINITIONS ARIBB1_DLL)
target_compile_definitions(aribb1-objlib PRIVATE ENABLE_ARIB_STD_B1)
Expand Down Expand Up @@ -176,9 +187,9 @@ configure_file(aribb25/version_b1.rc.in version_b1.rc @ONLY)
# ---------- libaribb25 ----------

if(WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "(ARM|ARM64|AARCH64)")
add_library(aribb25-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.c aribb25/multi2_simd.c aribb25/ts_section_parser.c aribb25/version_b25.c)
add_library(aribb25-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.c aribb25/multi2_simd.c aribb25/ts_section_parser.c aribb25/version_b25.c)
else()
add_library(aribb25-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.cc aribb25/ts_section_parser.c aribb25/version_b25.c)
add_library(aribb25-objlib OBJECT aribb25/arib_std_b25.c aribb25/b_cas_card.c aribb25/multi2.cc aribb25/ts_section_parser.c aribb25/version_b25.c)
endif()
set_target_properties(aribb25-objlib PROPERTIES COMPILE_DEFINITIONS ARIBB25_DLL)

Expand Down

0 comments on commit ada8d3e

Please sign in to comment.