Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Kral <vojtech@kral.hk>2019-01-09 20:20:23 +0300
committerGitHub <noreply@github.com>2019-01-09 20:20:23 +0300
commit5aec48418a0a55c0a9d5d9df4f6f4e680647fcee (patch)
treef9bf78657eac57d6c04dc9969573adc4c5562f45
parent0222492e29226fab81b79f35e35208f55c8a9d52 (diff)
parentd681eef10e9e3b83b1f9cbc65bab705ceb15e77a (diff)
Merge pull request #1613 from hexane360/cmake-fixes
CMake pre-compiled header and warning fixes
-rw-r--r--CMakeLists.txt17
-rw-r--r--cmake/modules/PrecompiledHeader.cmake28
2 files changed, 40 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fad1af6f3..04e023c09 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,14 +112,17 @@ if (APPLE)
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- # Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD.
- add_compile_options(-std=c++11 -Wall -Wno-reorder)
find_package(PkgConfig REQUIRED)
+
+ if (CMAKE_VERSION VERSION_LESS "3.1")
+ # Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ endif()
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
# Adding -fext-numeric-literals to enable GCC extensions on definitions of quad float literals, which are required by Boost.
- add_compile_options(-fext-numeric-literals)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals" )
if (SLIC3R_SYNTAXONLY)
set(CMAKE_CXX_ARCHIVE_CREATE "true")
@@ -136,9 +139,15 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ add_compile_options(-Wall)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" )
+
# On GCC and Clang, no return from a non-void function is a warning only. Here, we make it an error.
add_compile_options(-Werror=return-type)
+ #removes LOTS of extraneous Eigen warnings
+ add_compile_options(-Wno-ignored-attributes)
+
if (SLIC3R_ASAN)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
@@ -245,7 +254,7 @@ endif()
# Find eigen3 or use bundled version
if (NOT SLIC3R_STATIC)
- find_package(Eigen3)
+ find_package(Eigen3 3)
endif ()
if (NOT Eigen3_FOUND)
set(Eigen3_FOUND 1)
diff --git a/cmake/modules/PrecompiledHeader.cmake b/cmake/modules/PrecompiledHeader.cmake
index 2880da9f2..e46302144 100644
--- a/cmake/modules/PrecompiledHeader.cmake
+++ b/cmake/modules/PrecompiledHeader.cmake
@@ -68,11 +68,37 @@ function(export_all_flags _filename)
set(_compile_definitions "$<TARGET_PROPERTY:${_target},COMPILE_DEFINITIONS>")
set(_compile_flags "$<TARGET_PROPERTY:${_target},COMPILE_FLAGS>")
set(_compile_options "$<TARGET_PROPERTY:${_target},COMPILE_OPTIONS>")
+
+ #handle config-specific cxx flags
+ string(TOUPPER ${CMAKE_BUILD_TYPE} _config)
+ set(_build_cxx_flags ${CMAKE_CXX_FLAGS_${_config}})
+
+ #handle fpie option
+ get_target_property(_fpie ${_target} POSITION_INDEPENDENT_CODE)
+ if (_fpie AND CMAKE_POSITION_INDEPENDENT_CODE)
+ list(APPEND _compile_options ${CMAKE_CXX_COMPILE_OPTIONS_PIC})
+ endif()
+
+ #handle compiler standard (GCC only)
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ get_target_property(_cxx_standard ${_target} CXX_STANDARD)
+ if ((NOT "${_cxx_standard}" STREQUAL NOTFOUND) AND (NOT "${_cxx_standard}" STREQUAL ""))
+ get_target_property(_cxx_extensions ${_target} CXX_EXTENSIONS)
+ get_property(_exists TARGET ${_target} PROPERTY CXX_EXTENSIONS SET)
+ if (NOT _exists OR ${_cxx_extensions})
+ list(APPEND _compile_options "-std=gnu++${_cxx_standard}")
+ else()
+ list(APPEND _compile_options "-std=c++${_cxx_standard}")
+ endif()
+ endif()
+ endif()
+
set(_include_directories "$<$<BOOL:${_include_directories}>:-I$<JOIN:${_include_directories},\n-I>\n>")
set(_compile_definitions "$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions},\n-D>\n>")
set(_compile_flags "$<$<BOOL:${_compile_flags}>:$<JOIN:${_compile_flags},\n>\n>")
set(_compile_options "$<$<BOOL:${_compile_options}>:$<JOIN:${_compile_options},\n>\n>")
- file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}\n")
+ set(_cxx_flags "$<$<BOOL:${CMAKE_CXX_FLAGS}>:${CMAKE_CXX_FLAGS}\n>$<$<BOOL:${_build_cxx_flags}>:${_build_cxx_flags}\n>")
+ file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}${_cxx_flags}\n")
endfunction()
function(add_precompiled_header _target _input)