Warning, /graphics/digikam/core/cmake/rules/RulesWindows.cmake is written in an unsupported language. File is not indexed.

0001 #
0002 # SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005 #
0006 
0007 if(WIN32)
0008 
0009     if(MINGW)
0010 
0011         # For LibRaw
0012 
0013         find_library(WSOCK32_LIBRARY  wsock32)
0014         find_library(WS2_32_LIBRARY   ws2_32)
0015 
0016         # For MediaPlayer
0017 
0018         find_library(NETAPI32_LIBRARY netapi32)
0019         find_library(USEENV_LIBRARY   userenv)
0020         find_library(PSAPI_LIBRARY    psapi)
0021 
0022     else()  # MSVC
0023 
0024         # For LibRaw
0025 
0026         set(WSOCK32_LIBRARY  wsock32)
0027         set(WS2_32_LIBRARY   ws2_32)
0028 
0029         # For MediaPlayer
0030 
0031         set(NETAPI32_LIBRARY netapi32)
0032         set(USEENV_LIBRARY   userenv)
0033         set(PSAPI_LIBRARY    psapi)
0034 
0035     endif()
0036 
0037 endif()
0038 
0039 if(MINGW)
0040 
0041     # NOTE: cross-compilation rules inspired from https://phabricator.kde.org/T3917
0042 
0043     if(ENABLE_MINGW_HARDENING_LINKER)
0044 
0045         set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS}    -Wl,--dynamicbase -Wl,--nxcompat -Wl,--disable-auto-image-base")
0046         set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat -Wl,--disable-auto-image-base")
0047         set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat -Wl,--disable-auto-image-base")
0048 
0049         if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
0050 
0051             # Enable high-entropy ASLR for 64-bit
0052             # The image base has to be >4GB for HEASLR to be enabled.
0053             # The values used here are kind of arbitrary.
0054 
0055             set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS}    -Wl,--high-entropy-va -Wl,--image-base,0x140000000")
0056             set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--high-entropy-va -Wl,--image-base,0x180000000")
0057             set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--high-entropy-va -Wl,--image-base,0x180000000")
0058 
0059         endif()
0060 
0061         message(STATUS "MinGW linker Security Flags enabled")
0062 
0063     else()
0064 
0065         message(WARNING "MinGW Linker Security Flags not enabled!")
0066 
0067     endif()
0068 
0069 endif()
0070 
0071 # Increase the stack size to prevent crashes with GMic-qt.
0072 
0073 if(MSVC)
0074     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:16777216")
0075     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /STACK:16777216")
0076     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /STACK:16777216")
0077 elseif(MINGW)
0078     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216")
0079     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--stack,16777216")
0080     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--stack,16777216")
0081 endif()
0082 
0083 # Disable indeep warnings from Visual Studio C++
0084 
0085 if(MSVC)
0086 
0087     # To disable warnings about no suitable definition provided for explicit template instantiation request.
0088     add_compile_options(/wd4661)
0089     # To disable warnings about deprecated POSIX methods().
0090     add_compile_options(/wd4996)
0091     # To disable warnings about qualifier applied to reference type ignored.
0092     add_compile_options(/wd4181)
0093     # To disable warnings about 'storage-class-keyword' no longer supported as storage class.
0094     add_compile_options(/wd5033)
0095     # To disable warnings about size_t to uint conversion data lost.
0096     add_compile_options(/wd4267)
0097     # To disable warnings about truncation from double to float.
0098     add_compile_options(/wd4305)
0099     # To disable warnings about linking object specified multiple times.
0100     add_link_options(/ignore:4197)
0101 
0102 endif()