Skip to content
Snippets Groups Projects
Commit c660aa32 authored by Stefan Girke's avatar Stefan Girke
Browse files

simplified/improved codegenerator cmake script

parent bc14cc7e
No related branches found
No related tags found
No related merge requests found
function(add_code_generate_targets _target)
function(add_code_generate_targets)
get_target_property( compiledefs ${_target} COMPILE_DEFINITIONS )
string(REPLACE "compiledefs-NOTFOUND" "" compiledefs "${compiledefs}")
foreach(_target ${ARGN})
#check whether targets are already set up correctly
if( TARGET ${_target} )
#obtain compile definitions
get_target_property( compiledefs ${_target} COMPILE_DEFINITIONS )
string(REPLACE "compiledefs-NOTFOUND" "" compiledefs "${compiledefs}")
#optain sources target depends on
get_target_property( compilesources ${_target} SOURCES )
string(REPLACE "compilesources-NOTFOUND" "" compilesources "${compilesources}")
#Add targets and executables
add_executable( ${_target}_generatecode ${ARGN} )
set_property(TARGET ${_target}_generatecode APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG;BASEFUNCTIONSET_CODEGEN_GENERATE;${compiledefs}")
dune_target_link_libraries( ${_target}_generatecode "${DUNE_LIBS}" )
#Add targets and executables
add_executable( ${_target}_generatecode ${compilesources} )
set_property(TARGET ${_target}_generatecode APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG;BASEFUNCTIONSET_CODEGEN_GENERATE;${compiledefs}")
dune_target_link_libraries( ${_target}_generatecode "${DUNE_LIBS}" )
add_executable( ${_target}_compilecode ${ARGN} )
set_property(TARGET ${_target}_compilecode APPEND PROPERTY COMPILE_DEFINITIONS "NUSE_BASEFUNCTIONSET_CODEGEN;${compiledefs}")
dune_target_link_libraries( ${_target}_compilecode "${DUNE_LIBS}" )
add_executable( ${_target}_compilecode ${compilesources} )
set_property(TARGET ${_target}_compilecode APPEND PROPERTY COMPILE_DEFINITIONS "NUSE_BASEFUNCTIONSET_CODEGEN;${compiledefs}")
dune_target_link_libraries( ${_target}_compilecode "${DUNE_LIBS}" )
add_custom_target( ${_target}_generate
${CMAKE_COMMAND} -D RUN_CODEGEN_PROGRAM=${CMAKE_CURRENT_BINARY_DIR}/${_target}_generatecode -D RUN_CODEGEN_PARAMFILE="" -P ${CMAKE_SOURCE_DIR}/cmake/scripts/RunGenerate.cmake )
add_custom_target( ${_target}_codegen )
add_custom_target( ${_target}_generate
${CMAKE_COMMAND} -D RUN_CODEGEN_PROGRAM=${CMAKE_CURRENT_BINARY_DIR}/${_target}_generatecode -D RUN_CODEGEN_PARAMFILE="" -P ${CMAKE_SOURCE_DIR}/cmake/scripts/RunGenerate.cmake )
add_custom_target( ${_target}_codegen )
#Add depenencies
add_dependencies( ${_target}_generate ${_target}_generatecode )
add_dependencies( ${_target}_compilecode ${_target}_generate )
add_dependencies( ${_target}_codegen ${_target}_compilecode )
#Add depenencies
add_dependencies( ${_target}_generate ${_target}_generatecode )
add_dependencies( ${_target}_compilecode ${_target}_generate )
add_dependencies( ${_target}_codegen ${_target}_compilecode )
endif()
endforeach()
endfunction(add_code_generate_targets _target)
......@@ -18,7 +18,6 @@ dune_target_link_libraries(advdiff "${DUNE_LIBS}")
set_property(TARGET advdiff APPEND PROPERTY
COMPILE_DEFINITIONS "ONLY_ONE_P;POLORDER=2")
add_code_generate_targets( advdiff main.cc )
add_code_generate_targets( advdiffall main.cc )
add_code_generate_targets( advdiff advdiffall )
dune_add_test( advdiff advdiffall )
......@@ -20,4 +20,6 @@ dune_target_link_libraries(euler ${DUNE_LIBS})
set_property(TARGET euler APPEND PROPERTY
COMPILE_DEFINITIONS "ONLY_ONE_P;POLORDER=${POLORDER}")
add_code_generate_targets( euler eulerall )
dune_add_test( euler eulerall )
......@@ -19,4 +19,6 @@ dune_target_link_libraries(navierstokes ${DUNE_LIBS})
set_property(TARGET navierstokes APPEND PROPERTY
COMPILE_DEFINITIONS "ONLY_ONE_P;POLORDER=${POLORDER}")
add_code_generate_targets( navierstokes navierstokesall )
dune_add_test( navierstokes navierstokesall )
......@@ -21,4 +21,6 @@ dune_target_link_libraries(poisson ${DUNE_LIBS})
set_property(TARGET poisson APPEND PROPERTY
COMPILE_DEFINITIONS "ONLY_ONE_P;POLORDER=${POLORDER}")
add_code_generate_targets( poisson poissonall )
dune_add_test( poisson poissonall )
......@@ -21,4 +21,6 @@ dune_target_link_libraries(stokes "${DUNE_LIBS}")
set_property(TARGET stokes APPEND PROPERTY
COMPILE_DEFINITIONS "ONLY_ONE_P;POLORDER=2")
add_code_generate_targets( stokes stokesall )
dune_add_test( stokes stokesall )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment