@@ -7,56 +7,70 @@ collect (PROJECT_LIB_HEADERS metal-test.h)
77collect (PROJECT_LIB_TESTS version .c)
88collect (PROJECT_LIB_TESTS metal-test .c)
99
10- collector_list (_list PROJECT_INC_DIRS)
11- include_directories (${_list } ${CMAKE_CURRENT_SOURCE_DIR} )
10+ collector_list (_hdirs PROJECT_INC_DIRS)
11+ include_directories (${_hdirs } ${CMAKE_CURRENT_SOURCE_DIR} )
1212
13- collector_list (_list PROJECT_LIB_DIRS)
14- link_directories (${_list } )
13+ collector_list (_ldirs PROJECT_LIB_DIRS)
14+ link_directories (${_ldirs } )
1515
1616collector_list (_deps PROJECT_LIB_DEPS)
1717
18- collector_list (_list PROJECT_LIB_TESTS)
19-
20- if (WITH_SHARED_LIB)
21- set (_lib ${PROJECT_NAME} -shared)
22- add_executable (test -${_lib} ${_list} )
23- target_link_libraries (test -${_lib} ${_deps} ${_lib} )
24- install (TARGETS test -${_lib} RUNTIME DESTINATION bin)
25- if (PROJECT_EC_FLAGS)
26- string (REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS} )
27- target_compile_options (test -${_lib} PUBLIC ${_ec_flgs} )
28- endif (PROJECT_EC_FLAGS)
29- add_dependencies (test -${_lib} ${PROJECT_NAME} -shared)
30- if (WITH_TESTS_EXEC)
31- add_test (test -${_lib} test -${_lib} )
32- endif (WITH_TESTS_EXEC)
33- endif (WITH_SHARED_LIB)
34-
35- if (WITH_STATIC_LIB)
36- get_property (_linker_options GLOBAL PROPERTY TEST_LINKER_OPTIONS)
37- set (_lib ${PROJECT_NAME} -static )
38- add_executable (test -${_lib} ${_list} )
39- target_link_libraries (test -${_lib} -Wl,-Map=test -${_lib} .map ${_linker_options} -Wl,--start -group ${_lib} ${_deps} -Wl,--end -group)
40- install (TARGETS test -${_lib} RUNTIME DESTINATION bin)
41- if (PROJECT_EC_FLAGS)
42- string (REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS} )
43- target_compile_options (test -${_lib} PUBLIC ${_ec_flgs} )
44- endif (PROJECT_EC_FLAGS)
45- add_dependencies (test -${_lib} ${PROJECT_NAME} -static )
46- if (WITH_TESTS_EXEC)
47- add_test (test -${_lib} test -${_lib} )
48- endif (WITH_TESTS_EXEC)
49- endif (WITH_STATIC_LIB)
50-
51- collector_list (_headers PROJECT_HDR_TESTS)
52- foreach (INCLUDE ${_headers} )
53- string (REGEX REPLACE "[^a-zA-Z0-9]+" "-" _f ${INCLUDE} )
54- configure_file (metal-header-template.c ${_f} .c)
55- list (APPEND _flist "${CMAKE_CURRENT_BINARY_DIR} /${_f} " )
56- endforeach (INCLUDE )
57- add_library (metal-headers STATIC ${_flist} )
58-
59- collector_list (_list PROJECT_HDR_TESTS)
18+ collector_list (_srcs PROJECT_LIB_TESTS)
6019
20+ if (WITH_ZEPHYR)
21+ set (_tfiles "" )
22+ foreach (f ${_srcs} )
23+ list (APPEND _tfiles "${CMAKE_CURRENT_SOURCE_DIR} /${f} " )
24+ endforeach (f)
25+ target_sources (app PRIVATE ${_tfiles} )
26+ target_include_directories (app PRIVATE ${_hdirs} ${CMAKE_CURRENT_SOURCE_DIR} )
27+ set (_eldflags "" )
28+ foreach (d ${_ldirs} )
29+ list (APPEND _eldflags "-L${d} " )
30+ endforeach (d)
31+ add_dependencies (app metal)
32+ list (APPEND _deps -lmetal)
33+ target_link_libraries (app LINK_INTERFACE_LIBRARIES "${_eldflags} " ${_deps} )
34+ target_compile_options (app PRIVATE -DNOT_HAVE_STRERROR)
35+ else (WITH_ZEPHYR)
36+ if (WITH_SHARED_LIB)
37+ set (_lib ${PROJECT_NAME} -shared)
38+ add_executable (test -${_lib} ${_srcs} )
39+ target_link_libraries (test -${_lib} ${_deps} ${_lib} )
40+ install (TARGETS test -${_lib} RUNTIME DESTINATION bin)
41+ if (PROJECT_EC_FLAGS)
42+ string (REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS} )
43+ target_compile_options (test -${_lib} PUBLIC ${_ec_flgs} )
44+ endif (PROJECT_EC_FLAGS)
45+ add_dependencies (test -${_lib} ${PROJECT_NAME} -shared)
46+ if (WITH_TESTS_EXEC)
47+ add_test (test -${_lib} test -${_lib} )
48+ endif (WITH_TESTS_EXEC)
49+ endif (WITH_SHARED_LIB)
50+
51+ if (WITH_STATIC_LIB)
52+ get_property (_linker_options GLOBAL PROPERTY TEST_LINKER_OPTIONS)
53+ set (_lib ${PROJECT_NAME} -static )
54+ add_executable (test -${_lib} ${_srcs} )
55+ target_link_libraries (test -${_lib} -Wl,-Map=test -${_lib} .map ${_linker_options} -Wl,--start -group ${_lib} ${_deps} -Wl,--end -group)
56+ install (TARGETS test -${_lib} RUNTIME DESTINATION bin)
57+ if (PROJECT_EC_FLAGS)
58+ string (REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS} )
59+ target_compile_options (test -${_lib} PUBLIC ${_ec_flgs} )
60+ endif (PROJECT_EC_FLAGS)
61+ add_dependencies (test -${_lib} ${PROJECT_NAME} -static )
62+ if (WITH_TESTS_EXEC)
63+ add_test (test -${_lib} test -${_lib} )
64+ endif (WITH_TESTS_EXEC)
65+ endif (WITH_STATIC_LIB)
66+
67+ collector_list (_headers PROJECT_HDR_TESTS)
68+ foreach (INCLUDE ${_headers} )
69+ string (REGEX REPLACE "[^a-zA-Z0-9]+" "-" _f ${INCLUDE} )
70+ configure_file (metal-header-template.c ${_f} .c)
71+ list (APPEND _flist "${CMAKE_CURRENT_BINARY_DIR} /${_f} " )
72+ endforeach (INCLUDE )
73+ add_library (metal-headers STATIC ${_flist} )
74+ endif (WITH_ZEPHYR)
6175
6276# vim: expandtab:ts=2:sw=2:smartindent
0 commit comments