|
|
|
set(EXENAME odm)
|
|
|
|
set(ACTIONLISTINC ${CMAKE_CURRENT_BINARY_DIR}/../include/actionlist.h) # Include actions files and define the actions classes list
|
|
|
|
set(DATALISTINC ${CMAKE_CURRENT_BINARY_DIR}/../include/datalist.h) # Include data sources files and define the data sources 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} ${SOURCELISTINC})
|
|
|
|
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: ${Yellow}${act}${ColorReset} 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})
|
|
|
|
string(REGEX REPLACE "\.h$" ".cpp" actcpp "${actfile}")
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${actcpp} )
|
|
|
|
target_sources(${EXENAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${actcpp})
|
|
|
|
endif()
|
|
|
|
file(APPEND ${ACTIONLISTINC} "#include \"${actfile}\"\n")
|
|
|
|
endforeach(actfile)
|
|
|
|
# End generation of actions list
|
|
|
|
|
|
|
|
# Begin generation of data sources list
|
|
|
|
separate_arguments(excluded UNIX_COMMAND "${EXCLUDE_SOURCES}")
|
|
|
|
file(GLOB sourcefiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS ../sources/*.h ../sources-add/*.h)
|
|
|
|
foreach(sourcefile ${sourcefiles})
|
|
|
|
string(REGEX REPLACE "(\.h$|.*/)" "" source "${sourcefile}")
|
|
|
|
string(REGEX REPLACE "\.h$" ".cpp" sourcecpp "${sourcefile}")
|
|
|
|
if(NOT (("${source}" EQUAL "") OR ("${source}" IN_LIST excluded)))
|
|
|
|
message("Source: ${Cyan}${source}${ColorReset} in file ${sourcefile}")
|
|
|
|
list(APPEND sourcelist ${source})
|
|
|
|
list(APPEND sourcefilelist ${sourcefile})
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${sourcecpp} )
|
|
|
|
target_sources(${EXENAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${sourcecpp})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach(sourcefile)
|
|
|
|
|
|
|
|
list(TRANSFORM sourcelist APPEND "Data")
|
|
|
|
string(REPLACE ";" "," sourceclist "${sourcelist}")
|
|
|
|
file(WRITE ${DATALISTINC} "#define DATALIST ${sourceclist}\n")
|
|
|
|
|
|
|
|
foreach(sourcefile ${sourcefilelist})
|
|
|
|
file(APPEND ${DATALISTINC} "#include \"${sourcefile}\"\n")
|
|
|
|
endforeach(sourcefile)
|
|
|
|
# End generation of sources list
|