CMake: Add option for a syntax-only build

This commit is contained in:
Vojtech Kral 2018-11-20 22:59:56 +01:00
parent 18f14482d0
commit 4cb5c2a21b
3 changed files with 20 additions and 2 deletions

View file

@ -27,6 +27,7 @@ option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0)
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
option(SLIC3R_SYNTAXONLY "Only perform source code correctness checking, no binary output (UNIX only)" 0)
# Proposal for C++ unit tests and sandboxes
option(SLIC3R_BUILD_SANDBOXES "Build development sandboxes" OFF)
@ -96,6 +97,19 @@ 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)
if (SLIC3R_SYNTAXONLY)
set(CMAKE_CXX_ARCHIVE_CREATE "true")
set(CMAKE_C_ARCHIVE_CREATE "true")
set(CMAKE_CXX_ARCHIVE_APPEND "true")
set(CMAKE_C_ARCHIVE_APPEND "true")
set(CMAKE_RANLIB "true")
set(CMAKE_C_LINK_EXECUTABLE "true")
set(CMAKE_CXX_LINK_EXECUTABLE "true")
set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> -fsyntax-only <DEFINES> <INCLUDES> <FLAGS> -c <SOURCE> && touch <OBJECT>")
set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> -fsyntax-only <DEFINES> <INCLUDES> <FLAGS> -c <SOURCE> && touch <OBJECT>")
endif ()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")