programs: cmake: Use list of executables
Use list of executables to:
- factorize the code to define executables
- highlight the similarities and differences of the executable definitions
- avoid list duplication
Use alphabetic order for executables in lists.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt
index 4373ceb..4fe7952 100644
--- a/programs/psa/CMakeLists.txt
+++ b/programs/psa/CMakeLists.txt
@@ -1,12 +1,15 @@
-add_executable(crypto_examples crypto_examples.c)
-target_link_libraries(crypto_examples mbedtls)
+set(executables
+ crypto_examples
+ key_ladder_demo
+ psa_constant_names
+)
-add_executable(key_ladder_demo key_ladder_demo.c)
-target_link_libraries(key_ladder_demo mbedtls)
+foreach(exe IN LISTS executables)
+ add_executable(${exe} ${exe}.c)
+ target_link_libraries(${exe} mbedtls)
+endforeach()
-add_executable(psa_constant_names psa_constant_names.c)
target_include_directories(psa_constant_names PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
-target_link_libraries(psa_constant_names mbedtls)
add_custom_target(
psa_constant_names_generated
@@ -15,10 +18,7 @@
)
add_dependencies(psa_constant_names psa_constant_names_generated)
-install(TARGETS
- crypto_examples
- key_ladder_demo
- psa_constant_names
+install(TARGETS ${executables}
DESTINATION "bin"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)