diff --git a/CMakeLists.txt b/CMakeLists.txt index 18a3be3a3..2e3b406d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 " -fsyntax-only -c && touch ") + set(CMAKE_CXX_COMPILE_OBJECT " -fsyntax-only -c && touch ") + endif () endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 952b11ed0..3c3459f9d 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -168,7 +168,9 @@ add_library(libslic3r STATIC SLA/SLASpatIndex.hpp ) -add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE) +if (NOT SLIC3R_SYNTAXONLY) + add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE) +endif () target_compile_definitions(libslic3r PUBLIC -DUSE_TBB ${PNG_DEFINITIONS}) target_include_directories(libslic3r PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${LIBNEST2D_INCLUDES} ${PNG_INCLUDE_DIRS}) diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index f4bea7d36..18d48f2a5 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -126,4 +126,6 @@ add_library(libslic3r_gui STATIC ) target_link_libraries(libslic3r_gui libslic3r avrdude) -add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE) +if (NOT SLIC3R_SYNTAXONLY) + add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE) +endif ()