From 8aab5ca1356691c145c853529323130ca1cef881 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Mon, 19 Dec 2022 18:54:22 -0800 Subject: [PATCH] [build][cmake] Fix cmake with custom assembler Fixes cmake build when the C compiler isn't used as the assembler. We need to explicitly set the flag `-x assembler-with-cpp` to enable the preprocessor. Fixes #3193. --- build/cmake/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index f1eac9adad0..fff70018025 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -40,11 +40,13 @@ if( CMAKE_MAJOR_VERSION LESS 3 ) set(PROJECT_VERSION_PATCH ${zstd_VERSION_PATCH}) set(PROJECT_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}") enable_language(C) # Main library is in C + enable_language(ASM) # And ASM enable_language(CXX) # Testing contributed code also utilizes CXX else() project(zstd VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}" LANGUAGES C # Main library is in C + ASM # And ASM CXX # Testing contributed code also utilizes CXX ) endif() @@ -67,6 +69,7 @@ include(GNUInstallDirs) #----------------------------------------------------------------------------- include(AddZstdCompilationFlags) ADD_ZSTD_COMPILATION_FLAGS() +SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -x assembler-with-cpp") # Always hide XXHash symbols add_definitions(-DXXH_NAMESPACE=ZSTD_)