55# Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
66# See the attached LICENSE file for details.
77
8- cmake_minimum_required (VERSION 3.6.0)
8+ cmake_minimum_required (VERSION 3.16.0)
9+
10+ project (anjay_lite C)
911
1012# Core CMake code is located in cmake/anjay_lite-config.cmake and the library is
1113# supposed to be imported using find_package() mechanism - this file only meant
1214# to be a convenience wrapper for all example and test targets.
1315
14- project (anjay_lite C)
15-
1616set (CMAKE_C_STANDARD 99)
1717set (CMAKE_C_EXTENSIONS OFF )
1818
@@ -24,6 +24,17 @@ find_program(VALGRIND_EXECUTABLE valgrind)
2424
2525add_custom_target (run_tests)
2626
27+ # determine list of -D variables set by users, they need to be prefixed with CLI_
28+ get_cmake_property (_cache_vars CACHE_VARIABLES )
29+ set (COMMAND_LINE_FLAGS "" )
30+ foreach (_var ${_cache_vars} )
31+ if (_var MATCHES "CLI_" )
32+ list (APPEND COMMAND_LINE_FLAGS "-D${_var} =${${_var} }" )
33+ endif ()
34+ endforeach ()
35+
36+ message (STATUS "Command line flags: ${COMMAND_LINE_FLAGS} " )
37+
2738function (add_standalone_target NAME PATH WITH_VALGRIND)
2839 set (workdir "${CMAKE_BINARY_DIR} /${NAME} " )
2940
@@ -32,16 +43,18 @@ function(add_standalone_target NAME PATH WITH_VALGRIND)
3243
3344 add_custom_target (${NAME} ALL )
3445 add_custom_command (TARGET ${NAME} COMMAND ${CMAKE_COMMAND} -E make_directory
35- "${workdir} " )
46+ "${workdir} " PRE_BUILD )
3647 add_custom_command (
3748 TARGET ${NAME}
3849 COMMAND
3950 ${CMAKE_COMMAND} -S "${CMAKE_CURRENT_SOURCE_DIR} /${PATH} " -B .
4051 -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER} "
4152 -DCMAKE_C_FLAGS="${unescaped_c_flags} "
4253 -DCMAKE_EXE_LINKER_FLAGS="${unescaped_exe_linker_flags} "
54+ ${COMMAND_LINE_FLAGS}
4355 COMMAND ${CMAKE_COMMAND} --build . --target ${NAME} -- -j${NPROC}
44- WORKING_DIRECTORY "${workdir} " )
56+ WORKING_DIRECTORY "${workdir} "
57+ POST_BUILD)
4558
4659 if (WITH_VALGRIND AND VALGRIND_EXECUTABLE)
4760 add_custom_target (
@@ -53,7 +66,7 @@ function(add_standalone_target NAME PATH WITH_VALGRIND)
5366
5467 if (${NAME} MATCHES "_tests" )
5568 add_dependencies (run_tests ${NAME} )
56- add_custom_command (TARGET run_tests COMMAND "${workdir} /${NAME} " )
69+ add_custom_command (TARGET run_tests COMMAND "${workdir} /${NAME} " POST_BUILD )
5770 endif ()
5871endfunction ()
5972
@@ -68,9 +81,11 @@ add_standalone_target(io_tests_without_extended tests/anj/io_without_extended ON
6881add_standalone_target(coap_tests tests/anj/coap ON )
6982add_standalone_target(net_tests tests/anj/net ON )
7083add_standalone_target(core_tests tests/anj/core ON )
84+ add_standalone_target(downloader_tests tests/anj/downloader ON )
7185
7286# examples
7387add_standalone_target(anjay_lite_firmware_update examples/tutorial/firmware-update OFF )
88+ add_standalone_target(anjay_lite_firmware_update_pull examples/tutorial/firmware-update-coap-downloader OFF )
7489
7590add_standalone_target(anjay_lite_bc_initialization examples/tutorial/BC-Initialization OFF )
7691add_standalone_target(anjay_lite_bc_mandatory_objects examples/tutorial/BC-MandatoryObjects OFF )
@@ -88,8 +103,20 @@ add_standalone_target(anjay_lite_at_multi_instance_resource_dynamic examples/tut
88103add_standalone_target(anjay_lite_minimal_network_api examples/custom-network/minimal OFF )
89104add_standalone_target(anjay_lite_reuse_port examples/custom-network/reuse-port OFF )
90105
106+ add_standalone_target(anjay_lite_mbedtls_build examples/tutorial/mbedtls-build OFF )
107+
91108# Sphinx and doxygen documentation
92109add_subdirectory (doc )
93110
94111# C++ header compatibility check
95112add_standalone_target(cxx_header_check tests/cxx_header_check OFF )
113+
114+ add_standalone_target(codegen_compilation_check tests/codegen/compilation OFF )
115+ add_standalone_target(codegen_object_registry_check tests/codegen/object_registry OFF )
116+ add_standalone_target(codegen_add_object_tests tests/codegen/add_object OFF )
117+
118+ # Check for correct inclusion of anj/init.h
119+ add_custom_target (init_header_check
120+ COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR} /tests/init_header_check/run_check.cmake"
121+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} "
122+ )
0 commit comments