The template file
bakeConv converts from bake to e.g. CMakeLists files, with the help of a config file and the template file. The template file contains unchanging parts and parts which have to be replaced. With these two files the output file can be generated.
bake provides e.g.
- BAKE_SOURCES - provides all source files
- BAKE_INCLUDES - provides all header files
To get to know all information, which bake provides, use e.g.
bake UnitTest -p projectName --conversion_info
All mandatory variables (BAKE_SOURCES, BAKE_INCLUDES) have to have the following appearance in the template file
$$(...) e.g. $$(BAKE_SOURCES)
Optional variables e.g. BAKE_DEPENDENCIES have the following syntax
$OPTION(...) e.g. $OPTION(BAKE_DEPENDENCIES)
Examples:
template_libraryWithUnitTest.txt |
setSubdomain(all)
get_filename_component(folderName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(targetName ${ZSG_CURRENT_DOMAIN}_${ZSG_CURRENT_SUB_DOMAIN}_${folderName})
include_directories(
$$(BAKE_INCLUDES)
)
set (sourceFiles
${CMAKE_CURRENT_SOURCE_DIR}/$$(BAKE_SOURCES)
)
if(ZSG_BUILD_SCOPE STREQUAL "Application")
add_zsg_library(${targetName} STATIC ${sourceFiles})
elseif(ZSG_BUILD_SCOPE STREQUAL "UnitTest" AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_subdirectory(test)
endif()
|
template_UnitTest.txt |
add_definitions( -DUNIT_TEST )
include_directories(
$$(BAKE_INCLUDES)
)
set (sourceFilesUnitTest
$$(BAKE_SOURCES)
)
add_test_executable(gtest_${targetName}
${sourceFilesUnitTest}
)
add_test_library(gtest_${targetName}_sut STATIC ${sourceFiles})
set (testFrameworkTarget "")
$OPTION(GMOCK_TEMPLATE)
target_link_libraries(gtest_${targetName}
gtest_${targetName}_sut
gtest_esr_all_$OPTION(BAKE_DEPENDENCIES)_sut
${testFrameworkTarget}
)
|
template_GMock.txt (will be inserted in template_UnitTest.txt and replace $$(GMOCK_TEMPLATE)) |
includeTestFrameworkDirectories(GMock)
getTestFrameworkLibTarget("GMock" testFrameworkTarget)
|
Note: All templates which should be used have to be defined in your config file.