Accepting request 930074 from home:gladiac:branches:graphics

- Enable Link Time Optimizations (LTO)
- Fix building with optflags
  * Added 0001-cmake-Set-target-compile-flags-correctly.patch

OBS-URL: https://build.opensuse.org/request/show/930074
OBS-URL: https://build.opensuse.org/package/show/graphics/gmic?expand=0&rev=63
This commit is contained in:
Christophe Giboudeaux 2021-11-08 09:11:33 +00:00 committed by Git OBS Bridge
parent 7a109ade99
commit b65edc1a99
3 changed files with 100 additions and 10 deletions

View File

@ -0,0 +1,91 @@
From f05f07d501710c7e1609ac7348e9190f791f6127 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@cryptomilk.org>
Date: Sun, 7 Nov 2021 19:58:24 +0100
Subject: [PATCH] cmake: Set target compile flags correctly
This will not overwrite what you set with CMAKE_CXX_FLAGS on the
command line. Currently flags set by distributions are ignored when
packaging gmic.
---
CMakeLists.txt | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c6c4101..63a783f9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,15 +96,15 @@ endif()
# compile flags
set(CMAKE_POSITION_INDEPENDENT_CODE True)
-set(COMPILE_FLAGS "-Dgmic_build -Dcimg_use_vt100 -Dgmic_is_parallel -Dcimg_use_abort")
+set(GMIC_CXX_COMPILE_FLAGS "-Dgmic_build -Dcimg_use_vt100 -Dgmic_is_parallel -Dcimg_use_abort")
if(APPLE)
- set(COMPILE_FLAGS "${COMPILE_FLAGS} -mmacosx-version-min=10.8 -stdlib=libc++ -Wno-error=c++11-narrowing -Wc++11-extensions -fpermissive")
+ list(APPEND GMIC_CXX_COMPILE_FLAGS -mmacosx-version-min=10.8 -stdlib=libc++ -Wno-error=c++11-narrowing -Wc++11-extensions -fpermissive)
else()
- set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-error=narrowing -fno-ipa-sra -fpermissive")
+ list(APPEND GMIC_CXX_COMPILE_FLAGS -Wno-error=narrowing -fno-ipa-sra -fpermissive)
endif()
if(NOT "${PRERELEASE_TAG}" STREQUAL "")
- set(COMPILE_FLAGS "${COMPILE_FLAGS} -Dgmic_prerelease=\"${PRERELEASE_TAG}\"")
+ list(APPEND GMIC_CXX_COMPILE_FLAGS "-Dgmic_prerelease=\"${PRERELEASE_TAG}\"")
endif()
if (ENABLE_LTO)
@@ -126,14 +126,20 @@ if(ENABLE_DYNAMIC_LINKING)
set(CMAKE_SKIP_RPATH TRUE)
endif()
-set(CMAKE_CXX_FLAGS_DEBUG "-g -ansi -Wall -Wextra -pedantic -Dcimg_verbosity=3 ${COMPILE_FLAGS}")
-set(CMAKE_CXX_FLAGS_RELEASE "${COMPILE_FLAGS}")
-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g ${COMPILE_FLAGS}")
+string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
+if (${CMAKE_BUILD_TYPE_LOWER} STREQUAL "debug")
+ list(PREPEND GMIC_CXX_COMPILE_FLAGS -g -ansi -Wall -Wextra -pedantic -Dcimg_verbosity=3)
+endif()
+if (${CMAKE_BUILD_TYPE_LOWER} STREQUAL "relwithdebinfo")
+ list(PREPEND GMIC_CXX_COMPILE_FLAGS -g)
+endif()
-if(NOT CUSTOM_CFLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "-Og ${CMAKE_CXX_FLAGS_DEBUG}")
- set(CMAKE_CXX_FLAGS_RELEASE "-Ofast ${CMAKE_CXX_FLAGS_RELEASE}")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+if (NOT CUSTOM_CFLAGS)
+ if (${CMAKE_BUILD_TYPE_LOWER} STREQUAL "debug")
+ list(PREPEND GMIC_CXX_COMPILE_FLAGS -Og)
+ else()
+ list(PREPEND GMIC_CXX_COMPILE_FLAGS -Ofast)
+ endif()
endif()
# source files
@@ -141,6 +147,7 @@ set(CLI_Sources src/gmic.cpp)
if(BUILD_LIB)
add_library(libgmic SHARED ${CLI_Sources})
+ target_compile_options(libgmic PRIVATE ${GMIC_CXX_COMPILE_FLAGS})
set_target_properties(libgmic PROPERTIES SOVERSION "1" OUTPUT_NAME "gmic")
target_link_libraries(libgmic
CImg::CImg
@@ -164,6 +171,7 @@ endif()
if(BUILD_LIB_STATIC)
add_library(libgmicstatic STATIC ${CLI_Sources})
+ target_compile_options(libgmicstatic PRIVATE ${GMIC_CXX_COMPILE_FLAGS})
set_target_properties(libgmicstatic PROPERTIES OUTPUT_NAME "gmic")
target_link_libraries(libgmicstatic
CImg::CImg
@@ -182,6 +190,7 @@ endif()
if(BUILD_CLI)
add_executable(gmic src/gmic_cli.cpp)
+ target_compile_options(gmic PRIVATE ${GMIC_CXX_COMPILE_FLAGS})
if(ENABLE_DYNAMIC_LINKING)
target_link_libraries(gmic libgmic)
else()
--
2.33.1

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Sun Nov 7 13:48:14 UTC 2021 - Andreas Schneider <asn@cryptomilk.org>
- Enable Link Time Optimizations (LTO)
- Fix building with optflags
* Added 0001-cmake-Set-target-compile-flags-correctly.patch
-------------------------------------------------------------------
Sat Sep 11 14:54:42 UTC 2021 - Christophe Giboudeaux <christophe@krop.fr>

View File

@ -16,15 +16,6 @@
#
# Disable LTO as it removes important symbols
#
# g++ use_libgmic.cpp -o use_gmic -L/tmp/local/gmic/lib64 -lgmic
# use_libgmic.cpp:function main: error: undefined reference to 'cimg_library::CImgList<float>::assign(unsigned int)'
#
# https://discuss.pixls.us/t/gmic-lookup-symbol-err-on-opensuse-darktable-master-build/15827
#
%define _lto_cflags %{nil}
%global _gimpplugindir %(gimptool-2.0 --gimpplugindir)/plug-ins
Name: gmic
Version: 2.9.9
@ -35,9 +26,10 @@ Summary: GREYC's Magick for Image Computing (denoise and others)
License: CECILL-2.1
Group: Productivity/Graphics/Bitmap Editors
URL: https://gmic.eu
# Git URL: https://framagit.org/dtschump/gmic
# Git URL: https://github.com/dtschump/gmic
Source0: https://gmic.eu/files/source/gmic_%{version}.tar.gz
Source1: gmic_qt.png
Patch0: 0001-cmake-Set-target-compile-flags-correctly.patch
BuildRequires: cmake >= 3.14.0
BuildRequires: fftw3-threads-devel
BuildRequires: pkgconfig