diff options
author | Damjan Marion <damarion@cisco.com> | 2021-05-10 14:51:44 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2021-05-11 12:36:11 +0200 |
commit | 0d39cbac6d688fb98d05c32acec699b25a599ead (patch) | |
tree | 310b33f4b48b6aa342b0f1d398678b1e78ace81b /src/cmake | |
parent | 033e6ef52473aa3a87b1fe6db64114258106304b (diff) |
build: compiler flags handling cleanup
Type: make
Change-Id: I51f30edb91e09525ba116fe3941f2e43f9718da7
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/cmake')
-rw-r--r-- | src/cmake/cpu.cmake | 6 | ||||
-rw-r--r-- | src/cmake/exec.cmake | 1 | ||||
-rw-r--r-- | src/cmake/library.cmake | 2 | ||||
-rw-r--r-- | src/cmake/plugin.cmake | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake index 539f7c803a9..f4a57a34281 100644 --- a/src/cmake/cpu.cmake +++ b/src/cmake/cpu.cmake @@ -115,7 +115,7 @@ macro(add_vpp_march_variant v) endmacro() if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") - set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}") + set(VPP_DEFAULT_MARCH_FLAGS -march=corei7 -mtune=corei7-avx) add_vpp_march_variant(hsw FLAGS -march=haswell -mtune=haswell @@ -138,7 +138,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") ) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)") - set(CMAKE_C_FLAGS "-march=armv8-a+crc ${CMAKE_C_FLAGS}") + set(VPP_DEFAULT_MARCH_FLAGS -march=armv8-a+crc) add_vpp_march_variant(qdf24xx FLAGS -march=armv8-a+crc+crypto -mtune=qdf24xx @@ -198,7 +198,7 @@ macro(vpp_library_set_multiarch_sources lib) add_dependencies(${l} ${ARG_DEPENDS}) endif() set_target_properties(${l} PROPERTIES POSITION_INDEPENDENT_CODE ON) - target_compile_options(${l} PUBLIC "-DCLIB_MARCH_VARIANT=${VARIANT}") + target_compile_definitions(${l} PUBLIC CLIB_MARCH_VARIANT=${VARIANT}) separate_arguments(VARIANT_FLAGS) target_compile_options(${l} PUBLIC ${VARIANT_FLAGS}) target_sources(${lib} PRIVATE $<TARGET_OBJECTS:${l}>) diff --git a/src/cmake/exec.cmake b/src/cmake/exec.cmake index 7bfd5751c83..3ccbeee751c 100644 --- a/src/cmake/exec.cmake +++ b/src/cmake/exec.cmake @@ -20,6 +20,7 @@ macro(add_vpp_executable exec) ) add_executable(${exec} ${ARG_SOURCES}) + target_compile_options(${exec} PUBLIC ${VPP_DEFAULT_MARCH_FLAGS}) if(ARG_LINK_LIBRARIES) target_link_libraries(${exec} ${ARG_LINK_LIBRARIES}) endif() diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake index 5a7d2cdfef7..560b2c97d5c 100644 --- a/src/cmake/library.cmake +++ b/src/cmake/library.cmake @@ -22,6 +22,7 @@ macro(add_vpp_library lib) set (lo ${lib}_objs) add_library(${lo} OBJECT ${ARG_SOURCES}) set_target_properties(${lo} PROPERTIES POSITION_INDEPENDENT_CODE ON) + target_compile_options(${lo} PUBLIC ${VPP_DEFAULT_MARCH_FLAGS}) add_library(${lib} SHARED) target_sources(${lib} PRIVATE $<TARGET_OBJECTS:${lo}>) @@ -118,6 +119,7 @@ macro(add_vpp_test_library lib) get_filename_component(name ${file} NAME_WE) set(test_lib ${lib}_${name}_plugin) add_library(${test_lib} SHARED ${file}_test2.c) + target_compile_options(${test_lib} PUBLIC ${VPP_DEFAULT_MARCH_FLAGS}) if(NOT VPP_EXTERNAL_PROJECT) add_dependencies(${test_lib} api_headers) endif() diff --git a/src/cmake/plugin.cmake b/src/cmake/plugin.cmake index 8038dfa1981..b399470db02 100644 --- a/src/cmake/plugin.cmake +++ b/src/cmake/plugin.cmake @@ -45,6 +45,7 @@ macro(add_vpp_plugin name) ) endforeach() add_library(${plugin_name} SHARED ${api_includes} ${PLUGIN_SOURCES}) + target_compile_options(${plugin_name} PUBLIC ${VPP_DEFAULT_MARCH_FLAGS}) set_target_properties(${plugin_name} PROPERTIES NO_SONAME 1) target_compile_options(${plugin_name} PRIVATE "-fvisibility=hidden") target_compile_options (${plugin_name} PRIVATE "-ffunction-sections") @@ -90,6 +91,7 @@ macro(add_vpp_plugin name) set(test_plugin_name ${name}_test_plugin) add_library(${test_plugin_name} SHARED ${PLUGIN_API_TEST_SOURCES} ${api_includes}) + target_compile_options(${test_plugin_name} PUBLIC ${VPP_DEFAULT_MARCH_FLAGS}) set_target_properties(${test_plugin_name} PROPERTIES NO_SONAME 1) if(NOT VPP_EXTERNAL_PROJECT) add_dependencies(${test_plugin_name} api_headers) |