set(EXENAME odm) set(ACTIONLISTINC ${CMAKE_CURRENT_BINARY_DIR}/../include/actionlist.h) # Include actions files and define the actions classes list find_library(netcdf netcdf REQUIRED) find_package(OpenMP REQUIRED) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") file(GLOB srcs CONFIGURE_DEPENDS *.cpp) add_executable(${EXENAME} ${srcs} ${ACTIONLISTINC}) target_include_directories(${EXENAME} PRIVATE ../michlib/michlib ${CMAKE_CURRENT_BINARY_DIR}/../include) target_link_libraries(${EXENAME} ${linker_options} ${netcdf} OpenMP::OpenMP_CXX teos) set_target_properties(${EXENAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) install(TARGETS ${EXENAME}) # Begin generation of actions list get_target_property(INCS ${EXENAME} INCLUDE_DIRECTORIES) list(TRANSFORM INCS PREPEND "-I") separate_arguments(excluded UNIX_COMMAND "${EXCLUDE_ACTIONS}") file(GLOB actfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS ../actions/action*.h ../actions-add/action*.h) foreach(actfile ${actfiles}) execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${INCS} -E -DGENACTIONLIST ${actfile} OUTPUT_VARIABLE outfull ERROR_VARIABLE err WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) string(REGEX MATCH "ADD ACTION CLASS: [^ ;\n]+" outstr "${outfull}") string(REGEX REPLACE ".+: " "" act "${outstr}") if(NOT (("${act}" EQUAL "") OR ("${act}" IN_LIST excluded))) message("Action: ${act} in file ${actfile}") list(APPEND actlist ${act}) list(APPEND actfilelist ${actfile}) endif() endforeach(actfile) list(TRANSFORM actlist PREPEND "Action") string(REPLACE ";" "," actclist "${actlist}") file(WRITE ${ACTIONLISTINC} "#define ACTLIST ${actclist}\n") foreach(actfile ${actfilelist}) file(APPEND ${ACTIONLISTINC} "#include \"${actfile}\"\n") endforeach(actfile) # End generation of actions list