1*4882a593SmuzhiyunFrom f480ac538eb69086d4b7db855c2a457d5d6420d4 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3*4882a593SmuzhiyunDate: Mon, 10 Feb 2020 14:05:12 +0100
4*4882a593SmuzhiyunSubject: [PATCH] CMake/Utils/PrecompiledHeader.cmake: Add -c argument to build
5*4882a593Smuzhiyun precompiled headers
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunAdd "-c" argument when building precompiled headers to fix build with
8*4882a593SmuzhiyunRELRO.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunMore information on a similar issue with domoticz can be found here:
11*4882a593Smuzhiyunhttps://patchwork.ozlabs.org/patch/1187328:
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun"The problem AFAICS is that if no -c or similar option is given, GCC
14*4882a593Smuzhiyundecides what needs to be done based on the rest of the arguments. If the
15*4882a593Smuzhiyunrest of the arguments include a -Wl,... option, it decides that linking
16*4882a593Smuzhiyunneeds to be done. If the rest of the arguments are just header files, it
17*4882a593Smuzhiyundecides to create a precompiled header."
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunFixes:
20*4882a593Smuzhiyun - http://autobuild.buildroot.org/results/8fabf8d270b9257c3a9db6a2f17f1c08ec9428d3
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
23*4882a593Smuzhiyun[Upstream: https://github.com/OGRECave/ogre/commit/de4d5c920e23e1e2b21dc5c8192ef74ba6210cca]
24*4882a593Smuzhiyun---
25*4882a593Smuzhiyun CMake/Utils/PrecompiledHeader.cmake | 6 +++---
26*4882a593Smuzhiyun 1 file changed, 3 insertions(+), 3 deletions(-)
27*4882a593Smuzhiyun
28*4882a593Smuzhiyundiff --git a/CMake/Utils/PrecompiledHeader.cmake b/CMake/Utils/PrecompiledHeader.cmake
29*4882a593Smuzhiyunindex a02d99acd..bfb0059db 100644
30*4882a593Smuzhiyun--- a/CMake/Utils/PrecompiledHeader.cmake
31*4882a593Smuzhiyun+++ b/CMake/Utils/PrecompiledHeader.cmake
32*4882a593Smuzhiyun@@ -133,11 +133,11 @@ MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
33*4882a593Smuzhiyun             STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun             SET(${out_command}
36*4882a593Smuzhiyun-              ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
37*4882a593Smuzhiyun+              ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x c++-header -c -o ${_output} ${_input}
38*4882a593Smuzhiyun               )
39*4882a593Smuzhiyun         ELSE(CMAKE_CXX_COMPILER_ARG1)
40*4882a593Smuzhiyun             SET(${out_command}
41*4882a593Smuzhiyun-              ${CMAKE_CXX_COMPILER}  ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
42*4882a593Smuzhiyun+              ${CMAKE_CXX_COMPILER}  ${_compile_FLAGS} -x c++-header -c -o ${_output} ${_input}
43*4882a593Smuzhiyun               )
44*4882a593Smuzhiyun         ENDIF(CMAKE_CXX_COMPILER_ARG1)
45*4882a593Smuzhiyun     ELSE(CMAKE_COMPILER_IS_GNUCXX)
46*4882a593Smuzhiyun@@ -291,7 +291,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
47*4882a593Smuzhiyun     set_target_properties(${_targetName}_pch_dephelp PROPERTIES INCLUDE_DIRECTORIES "${DIRINC}")
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun     #MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
50*4882a593Smuzhiyun-    #message("COMMAND ${CMAKE_CXX_COMPILER}	${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
51*4882a593Smuzhiyun+    #message("COMMAND ${CMAKE_CXX_COMPILER}	${_compile_FLAGS} -x c++-header -c -o ${_output} ${_input}")
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun     ADD_CUSTOM_COMMAND(
54*4882a593Smuzhiyun       OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_name}"
55*4882a593Smuzhiyun--
56*4882a593Smuzhiyun2.24.1
57*4882a593Smuzhiyun
58