diff --git a/cmake/options.cmake b/cmake/options.cmake index d6cf5686..9e51db4d 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -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 diff --git a/examples/system/freertos/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt b/examples/system/freertos/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt index 3b4cf7b5..c0576733 100644 --- a/examples/system/freertos/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt +++ b/examples/system/freertos/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt @@ -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) diff --git a/examples/system/generic/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt b/examples/system/generic/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt index 3b4cf7b5..c0576733 100644 --- a/examples/system/generic/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt +++ b/examples/system/generic/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt @@ -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) diff --git a/examples/system/linux/zynqmp/zynqmp_amp_demo/CMakeLists.txt b/examples/system/linux/zynqmp/zynqmp_amp_demo/CMakeLists.txt index 30625055..1bdb59b8 100644 --- a/examples/system/linux/zynqmp/zynqmp_amp_demo/CMakeLists.txt +++ b/examples/system/linux/zynqmp/zynqmp_amp_demo/CMakeLists.txt @@ -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") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 121e0c64..e9d52767 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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}" ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c0f40ccc..47846ae3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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})