1- # To build one or more schemas, configure with
1+ # To build one or more schemas, configure with
22# 'cmake -DSCL_BUILD_SCHEMAS="path/to/schema.exp;path/to/schema2.exp"
33
4- # This function runs fedex on one express file. The generated source goes in a dir
5- # in the build dir, and it is compiled into a library. A p21read executable is
4+ # This function runs fedex on one express file. The generated source goes in a dir
5+ # in the build dir, and it is compiled into a library. A p21read executable is
66# compiled and linked to the lib. p21read is used to test the lib.
77FUNCTION (BUILD_A_SCHEMA SCHEMA_FILE )
88 if ( EXISTS "${CMAKE_BINARY_DIR} /${SCHEMA_FILE} " ) #try absolute path. if that fails, must already be absolute.
@@ -27,7 +27,7 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
2727 string (TOUPPER ${SCHEMA_N} SCHEMA_LONG_NAME) #fedex_plus always uses upper case for file names
2828 get_filename_component ( SCHEMA_SN ${SCHEMA_FILE} NAME )
2929 string ( REGEX REPLACE "\( .*\) .[Ee][Xx][Pp]" "\\ 1" SCHEMA_SHORT_NAME ${SCHEMA_SN} )
30-
30+
3131 project ( sdai_${SCHEMA_SHORT_NAME} )
3232 message ( STATUS "Generating code for ${SCHEMA_SHORT_NAME} ." )
3333 set ( SCHEMA_OUTPUT_DIR ${CMAKE_BINARY_DIR} /${SCHEMA_SHORT_NAME} )
@@ -54,12 +54,24 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
5454 WORKING_DIRECTORY ${SCHEMA_OUTPUT_DIR}
5555 COMMENT "Running fedex_plus for ${SCHEMA_SHORT_NAME} ..."
5656 VERBATIM )
57+
58+ if ( SCL_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
59+ # Coverage will always be sparse on schema libs. Compiling the libs with the -fprofile-arcs and
60+ # -ftest-coverage is extremely slow. We can avoid that by temporarily changing build type to release.
61+ set ( PREV_BUILD_TYPE ${CMAKE_BUILD_TYPE} )
62+ set ( CMAKE_BUILD_TYPE "Release" )
63+ endif ( SCL_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
64+
5765 # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
5866 SCL_ADDLIB ( ${PROJECT_NAME} "${FEDEX_OUT} " "stepdai stepcore express stepeditor steputils base" "TESTABLE" )
5967 add_dependencies ( ${PROJECT_NAME} generate_cpp_${SCHEMA_SHORT_NAME} )
6068 set_target_properties ( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
6169 ${${PROJECT_NAME}_COMPILE_FLAGS} )
6270
71+ if ( SCL_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
72+ set ( CMAKE_BUILD_TYPE ${PREV_BUILD_TYPE} )
73+ endif ( SCL_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
74+
6375 add_test ( NAME generate_cpp_${SCHEMA_SHORT_NAME}
6476 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
6577 COMMAND ${CMAKE_COMMAND} --build .
@@ -93,6 +105,8 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
93105
94106ENDFUNCTION (BUILD_A_SCHEMA )
95107
108+ #----------------------------------------------------------------------------------------------------
109+
96110if ( DEFINED SCL_BUILD_SCHEMAS )
97111 if ( SCL_BUILD_SCHEMAS STREQUAL "ALL" )
98112 file ( GLOB_RECURSE SCL_BUILD_SCHEMAS ${SCL_SOURCE_DIR} /data/*.exp )
0 commit comments