Give the compile flags an EXECUTABLE_ prefix.
The fPIE flag should only be used with executables. Change-Id: If799ae4a7fe2492af3aac67651659a52d365024a Reviewed-by: Alexander Neundorf <neundorf@kde.org> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
1386e68b2b
commit
361cd9f9b2
@ -21,10 +21,14 @@ foreach(_module_dep ${_Qt5_MODULE_DEPENDENCIES})
|
|||||||
list(APPEND Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS ${Qt5${_module_dep}_INCLUDE_DIRS})
|
list(APPEND Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS ${Qt5${_module_dep}_INCLUDE_DIRS})
|
||||||
list(APPEND Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS})
|
list(APPEND Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS})
|
||||||
list(APPEND Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS})
|
list(APPEND Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS})
|
||||||
|
list(APPEND Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS})
|
||||||
endforeach()
|
endforeach()
|
||||||
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS)
|
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS)
|
||||||
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS)
|
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_DEFINITIONS)
|
||||||
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS)
|
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_COMPILE_DEFINITIONS)
|
||||||
|
if (Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS)
|
||||||
|
list(REMOVE_DUPLICATES Qt5$${CMAKE_MODULE_NAME}_EXECUTABLE_COMPILE_FLAGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT _Qt5$${CMAKE_MODULE_NAME}_target)
|
if (NOT _Qt5$${CMAKE_MODULE_NAME}_target)
|
||||||
set(_Qt5$${CMAKE_MODULE_NAME}_target 1)
|
set(_Qt5$${CMAKE_MODULE_NAME}_target 1)
|
||||||
|
@ -9,7 +9,7 @@ set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/rcc$$CMAK
|
|||||||
list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5_corelib_install_prefix}/mkspecs/default\")
|
list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5_corelib_install_prefix}/mkspecs/default\")
|
||||||
|
|
||||||
if (NOT \"$${CMAKE_ADD_FPIE_FLAGS}\" STREQUAL \"\")
|
if (NOT \"$${CMAKE_ADD_FPIE_FLAGS}\" STREQUAL \"\")
|
||||||
set(Qt5Core_COMPILE_FLAGS "-fPIE")
|
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIE")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT \"$$QT_NAMESPACE\" STREQUAL \"\")
|
if (NOT \"$$QT_NAMESPACE\" STREQUAL \"\")
|
||||||
|
@ -16,5 +16,7 @@ qt5_wrap_cpp(moc_files myobject.h)
|
|||||||
# in the add_executable call.
|
# in the add_executable call.
|
||||||
qt5_add_resources(rcc_files "pass4.qrc" OPTIONS -binary)
|
qt5_add_resources(rcc_files "pass4.qrc" OPTIONS -binary)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
|
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
|
||||||
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
||||||
|
@ -13,5 +13,7 @@ add_definitions(${Qt5Core_DEFINITIONS})
|
|||||||
# causing a compile failure. -> Options work
|
# causing a compile failure. -> Options work
|
||||||
qt5_wrap_cpp(moc_files myobject.h OPTIONS -i)
|
qt5_wrap_cpp(moc_files myobject.h OPTIONS -i)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
add_executable(myobject myobject.cpp ${moc_files})
|
add_executable(myobject myobject.cpp ${moc_files})
|
||||||
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
||||||
|
@ -16,5 +16,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||||||
qt5_wrap_cpp(moc_files mywidget.h)
|
qt5_wrap_cpp(moc_files mywidget.h)
|
||||||
qt5_wrap_ui(ui_files mywidget.ui)
|
qt5_wrap_ui(ui_files mywidget.ui)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files})
|
add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files})
|
||||||
target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES})
|
target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES})
|
||||||
|
@ -18,7 +18,23 @@ macro(qt5_use_package _target _package)
|
|||||||
# set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_package}_INCLUDE_DIRS})
|
# set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_package}_INCLUDE_DIRS})
|
||||||
include_directories(${Qt5${_package}_INCLUDE_DIRS})
|
include_directories(${Qt5${_package}_INCLUDE_DIRS})
|
||||||
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_package}_COMPILE_DEFINITIONS})
|
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_package}_COMPILE_DEFINITIONS})
|
||||||
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_FLAGS ${Qt5${_package}_COMPILE_FLAGS})
|
|
||||||
|
# We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list
|
||||||
|
# which breaks the compile commmand line.
|
||||||
|
# Ensure non-duplication here manually instead.
|
||||||
|
get_property(_taget_type TARGET ${_target} PROPERTY TYPE)
|
||||||
|
if ("${_taget_type}" STREQUAL "EXECUTABLE")
|
||||||
|
get_target_property(_flags ${_target} COMPILE_FLAGS)
|
||||||
|
if (_flags)
|
||||||
|
list(APPEND _flags ${Qt5${_package}_EXECUTABLE_COMPILE_FLAGS})
|
||||||
|
list(REMOVE_DUPLICATES _flags)
|
||||||
|
else()
|
||||||
|
set(_flags ${Qt5${_package}_EXECUTABLE_COMPILE_FLAGS})
|
||||||
|
endif()
|
||||||
|
if (_flags)
|
||||||
|
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "NOT FOUND: Qt5${_package}")
|
message(FATAL_ERROR "NOT FOUND: Qt5${_package}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -13,5 +13,7 @@ qt5_wrap_cpp(moc_files myobject.h)
|
|||||||
|
|
||||||
qt5_add_resources(rcc_files "pass2.qrc")
|
qt5_add_resources(rcc_files "pass2.qrc")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
|
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
|
||||||
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
||||||
|
@ -15,5 +15,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||||||
qt5_wrap_cpp(moc_files mywidget.h)
|
qt5_wrap_cpp(moc_files mywidget.h)
|
||||||
qt5_wrap_ui(ui_files mywidget.ui)
|
qt5_wrap_ui(ui_files mywidget.ui)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files})
|
add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files})
|
||||||
target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES})
|
target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES})
|
||||||
|
@ -8,4 +8,6 @@ find_package(Qt5Core REQUIRED)
|
|||||||
include_directories(${Qt5Core_INCLUDE_DIRS})
|
include_directories(${Qt5Core_INCLUDE_DIRS})
|
||||||
add_definitions(${Qt5Core_DEFINITIONS})
|
add_definitions(${Qt5Core_DEFINITIONS})
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
add_executable(myobject main.cpp)
|
add_executable(myobject main.cpp)
|
||||||
|
Loading…
Reference in New Issue
Block a user