]> www.ginac.de Git - cln.git/commitdiff
cmake: tell the compiler how to handle cl_asm_.cc
authorAlexey Sheplyakov <asheplyakov@altlinux.org>
Sat, 2 Jan 2021 09:21:01 +0000 (13:21 +0400)
committerAlexey Sheplyakov <asheplyakov@altlinux.org>
Sun, 3 Jan 2021 06:55:40 +0000 (10:55 +0400)
Pass `-x assembler-with-cpp` to GCC/Clang. Don't use asm loops with
other compilers.

src/CMakeLists.txt

index 5a7dc90c268fbbe29fb8262f170f05836cdf9c92..430580484d9e549682e2eb93eb3e54ebe16e737b 100644 (file)
@@ -50,7 +50,6 @@ set(cln_sources
        base/digitseq/cl_DS_sqrt.cc
        base/digitseq/cl_DS_trandom.cc
        base/digitseq/cl_asm.h
-       base/digitseq/cl_asm.S
        base/hash/cl_hash.h
        base/hash/cl_hash1.h
        base/hash/cl_hash1weak.h
@@ -944,12 +943,16 @@ set(cln_sources
        vector/output/cl_SV_number_aprint.cc
 )
 
-set(asm_sources base/digitseq/cl_asm.S)
-set_source_files_properties(${asm_sources} PROPERTIES
-       LANGUAGE C
-       COMPILE_FLAGS "${ASM_NOEXECSTACK_FLAG}")
+if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+       set(cln_asm_sources base/digitseq/cl_asm_.cc)
+       set_source_files_properties(${cln_asm_sources} PROPERTIES
+               LANGUAGE C
+               COMPILE_FLAGS "-x assembler-with-cpp ${ASM_NOEXECSTACK_FLAG}"
+       )
+       message(STATUS "enabling cl_asm.cc")
+endif()
 
-add_library(cln ${cln_sources})
+add_library(cln ${cln_sources} ${cln_asm_sources})
 add_library(cln::cln ALIAS cln)
 # The incantation below tells CMake to set the correct SONAME and use
 # the conventional libcln.so.SONAME.X.Y file name. The variables
@@ -961,6 +964,10 @@ set_target_properties(cln PROPERTIES
 if (CLN_USE_GMP)
        target_link_libraries(cln PRIVATE gmp::gmp)
 endif()
+if (NOT cln_asm_sources)
+       message(STATUS "disabling asm loops (only GCC and Clang are supported)")
+       target_compile_definitions(cln PRIVATE NO_ASM NO_ASM_LOOPS)
+endif()
 
 if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
        set_target_properties(cln PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")