Introduce "Dev mode" option
When the option is On, CMake will have rules to generate the generated
files using scripts etc. When the option is Off, CMake will assume the
files are available from the source tree; in that mode, it won't require
any extra tools (Perl for example) compared to when we committed the
files to git.
The intention is that users will never need to adjust this option:
- in the development branch (and features branches etc.) the option is
always On (development mode);
- in released tarballs, which include the generated files, we'll switch
the option to Off (release mode) in the same commit that re-adds the
generated files.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt
index 8193124..053b03c 100644
--- a/programs/test/CMakeLists.txt
+++ b/programs/test/CMakeLists.txt
@@ -27,26 +27,30 @@
target_link_libraries(cpp_dummy_build ${mbedcrypto_target})
endif()
-find_package(Perl REQUIRED)
+if(DEV_MODE)
+ find_package(Perl REQUIRED)
-add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/query_config.c
- COMMAND
- ${PERL}
+ add_custom_command(
+ OUTPUT
+ ${CMAKE_CURRENT_BINARY_DIR}/query_config.c
+ COMMAND
+ ${PERL}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
+ ${CMAKE_CURRENT_BINARY_DIR}/query_config.c
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
- ${CMAKE_CURRENT_BINARY_DIR}/query_config.c
- DEPENDS
- ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
- ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
- ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
-)
-# this file will also be used in anoter directory, so create a target, see
-# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory
-add_custom_target(generate_query_config_c
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c)
+ )
+ # this file will also be used in anoter directory, so create a target, see
+ # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory
+ add_custom_target(generate_query_config_c
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c)
+else()
+ link_to_source(query_config.c)
+endif()
foreach(exe IN LISTS executables_libs executables_mbedcrypto)
set(extra_sources "")