mirror of
https://github.com/OpenAMP/libmetal.git
synced 2026-09-23 18:53:40 +08:00
cmake: set PROJECT_EC_FLAGS to be GLOBAL property
Declare PROJECT_EC_FLAGS to be a global property to simplify code for target_compile_options. Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
This commit is contained in:
committed by
Arnaud Pouliquen
parent
9a814dac13
commit
d077e286a4
+1
-1
@@ -72,5 +72,5 @@ option (WITH_DEFAULT_LOGGER "Build with default logger" ON)
|
||||
|
||||
option (WITH_DOC "Build with documentation" ON)
|
||||
|
||||
set (PROJECT_EC_FLAGS "-Wall -Werror -Wextra" CACHE STRING "")
|
||||
set (GLOBAL PROPERTY "PROJECT_EC_FLAGS" "-Wall -Werror -Wextra" CACHE STRING "")
|
||||
# vim: expandtab:ts=2:sw=2:smartindent
|
||||
|
||||
@@ -21,10 +21,8 @@ list(APPEND _src0 ${CMAKE_CURRENT_SOURCE_DIR}/shmem_throughput_demod.c)
|
||||
|
||||
get_property (_linker_options GLOBAL PROPERTY TEST_LINKER_OPTIONS)
|
||||
add_executable (${_app0}.elf ${_src0})
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (${_app0}.elf PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
get_property (_ec_flgs GLOBAL PROPERTY "PROJECT_EC_FLAGS")
|
||||
target_compile_options (${_app0}.elf PUBLIC ${_ec_flgs})
|
||||
target_link_libraries(${_app0}.elf -Wl,-Map=${_app0}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
|
||||
install (TARGETS ${_app0}.elf RUNTIME DESTINATION bin)
|
||||
|
||||
|
||||
@@ -21,10 +21,8 @@ list(APPEND _src0 ${CMAKE_CURRENT_SOURCE_DIR}/shmem_throughput_demod.c)
|
||||
|
||||
get_property (_linker_options GLOBAL PROPERTY TEST_LINKER_OPTIONS)
|
||||
add_executable (${_app0}.elf ${_src0})
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (${_app0}.elf PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
get_property (_ec_flgs GLOBAL PROPERTY "PROJECT_EC_FLAGS")
|
||||
target_compile_options (${_app0}.elf PUBLIC ${_ec_flgs})
|
||||
target_link_libraries(${_app0}.elf -Wl,-Map=${_app0}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
|
||||
install (TARGETS ${_app0}.elf RUNTIME DESTINATION bin)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ link_directories (${_list})
|
||||
collector_list (_deps PROJECT_LIB_DEPS)
|
||||
|
||||
set (_src_common ${CMAKE_CURRENT_SOURCE_DIR}/sys_init.c)
|
||||
get_property (_ec_flgs GLOBAL PROPERTY "PROJECT_EC_FLAGS")
|
||||
foreach (_app libmetal_amp_demo libmetal_amp_demod)
|
||||
set (_src ${CMAKE_CURRENT_SOURCE_DIR}/${_app}.c)
|
||||
list(APPEND _src ${_src_common})
|
||||
@@ -18,10 +19,7 @@ foreach (_app libmetal_amp_demo libmetal_amp_demod)
|
||||
list(APPEND _src ${CMAKE_CURRENT_SOURCE_DIR}/shmem_throughput_demo.c)
|
||||
if (WITH_SHARED_LIB)
|
||||
add_executable (${_app}-share ${_src})
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (${_app}-share PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
target_compile_options (${_app}-share PUBLIC ${_ec_flgs})
|
||||
target_link_libraries (${_app}-share ${PROJECT_NAME}-shared ${_deps})
|
||||
install (TARGETS ${_app}-share RUNTIME DESTINATION bin)
|
||||
add_dependencies (${_app}-share ${PROJECT_NAME}-shared)
|
||||
@@ -30,10 +28,7 @@ foreach (_app libmetal_amp_demo libmetal_amp_demod)
|
||||
if (WITH_STATIC_LIB)
|
||||
if (${PROJECT_SYSTEM} STREQUAL "linux")
|
||||
add_executable (${_app}-static ${_src})
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (${_app}-static PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
target_compile_options (${_app}-static PUBLIC ${_ec_flgs})
|
||||
target_link_libraries (${_app}-static ${PROJECT_NAME}-static ${_deps})
|
||||
install (TARGETS ${_app}-static RUNTIME DESTINATION bin)
|
||||
endif (${PROJECT_SYSTEM} STREQUAL "linux")
|
||||
|
||||
+4
-8
@@ -65,6 +65,8 @@ if (WITH_DEFAULT_LOGGER)
|
||||
add_definitions (-DDEFAULT_LOGGER_ON)
|
||||
endif (WITH_DEFAULT_LOGGER)
|
||||
|
||||
get_property (_ec_flgs GLOBAL PROPERTY "PROJECT_EC_FLAGS")
|
||||
|
||||
if (WITH_ZEPHYR)
|
||||
zephyr_library_named(metal)
|
||||
add_dependencies(metal offsets_h)
|
||||
@@ -77,10 +79,7 @@ else (WITH_ZEPHYR)
|
||||
add_library (${_lib} SHARED ${_sources})
|
||||
target_link_libraries (${_lib} ${_deps})
|
||||
install (TARGETS ${_lib} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (${_lib} PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
target_compile_options (${_lib} PUBLIC ${_ec_flgs})
|
||||
set_target_properties (${_lib} PROPERTIES
|
||||
OUTPUT_NAME "${PROJECT_NAME}"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
@@ -93,10 +92,7 @@ else (WITH_ZEPHYR)
|
||||
set (_lib ${PROJECT_NAME}-static)
|
||||
add_library (${_lib} STATIC ${_sources})
|
||||
install (TARGETS ${_lib} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (${_lib} PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
target_compile_options (${_lib} PUBLIC ${_ec_flgs})
|
||||
set_target_properties (${_lib} PROPERTIES
|
||||
OUTPUT_NAME "${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
+4
-8
@@ -17,6 +17,8 @@ collector_list (_deps PROJECT_LIB_DEPS)
|
||||
|
||||
collector_list (_srcs PROJECT_LIB_TESTS)
|
||||
|
||||
get_property (_ec_flgs GLOBAL PROPERTY "PROJECT_EC_FLAGS")
|
||||
|
||||
if (WITH_ZEPHYR)
|
||||
set (_tfiles "")
|
||||
foreach (f ${_srcs})
|
||||
@@ -38,10 +40,7 @@ else (WITH_ZEPHYR)
|
||||
add_executable (test-${_lib} ${_srcs})
|
||||
target_link_libraries (test-${_lib} ${_deps} ${_lib})
|
||||
install (TARGETS test-${_lib} RUNTIME DESTINATION bin)
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (test-${_lib} PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
target_compile_options (test-${_lib} PUBLIC ${_ec_flgs})
|
||||
add_dependencies (test-${_lib} ${PROJECT_NAME}-shared)
|
||||
if (WITH_TESTS_EXEC)
|
||||
add_test (test-${_lib} test-${_lib})
|
||||
@@ -54,10 +53,7 @@ else (WITH_ZEPHYR)
|
||||
add_executable (test-${_lib} ${_srcs})
|
||||
target_link_libraries (test-${_lib} -Wl,-Map=test-${_lib}.map ${_linker_options} -Wl,--start-group ${_lib} ${_deps} -Wl,--end-group)
|
||||
install (TARGETS test-${_lib} RUNTIME DESTINATION bin)
|
||||
if (PROJECT_EC_FLAGS)
|
||||
string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS})
|
||||
target_compile_options (test-${_lib} PUBLIC ${_ec_flgs})
|
||||
endif (PROJECT_EC_FLAGS)
|
||||
target_compile_options (test-${_lib} PUBLIC ${_ec_flgs})
|
||||
add_dependencies (test-${_lib} ${PROJECT_NAME}-static)
|
||||
if (WITH_TESTS_EXEC)
|
||||
add_test (test-${_lib} test-${_lib})
|
||||
|
||||
Reference in New Issue
Block a user