Skip to content
Snippets Groups Projects
Commit 99149e8a authored by Markus Blatt's avatar Markus Blatt
Browse files

replace_properties now realy replaces them and not just appends new

ones. It works for multiple targets.

[[Imported from SVN: r6916]]
parent 6b6970ad
Branches
Tags
No related merge requests found
......@@ -160,9 +160,6 @@ macro(dune_module_information MODULE_DIR)
split_module_version(${DUNE_SUGGESTS} SUGGESTS_MODULE SUGGESTS_VERSION)
endif(DUNE_SUGGESTS)
message(STATUS "DEPENDENCIES: ${DEPENDS_MODULE} ${DEPENDS_VERSION}")
message(STATUS "DUGGESTIONS: ${SUGGESTS_MODULE} ${SUGGESTS_VERSION}")
dune_module_to_uppercase(DUNE_MOD_NAME_UPPERCASE ${DUNE_MOD_NAME})
# set module version
......@@ -203,7 +200,6 @@ macro(dune_module_to_macro _macro_name _dune_module)
endmacro(dune_module_to_macro _macro_name _dune_module)
macro(dune_process_dependency_tree DEPENDS DVERSIONS SUGGESTS SVERSIONS)
message(STATUS "Depends=${DEPENDS}")
message(STATUS "dune-geometry_PROCESSED=${dune-geometry_PROCESSED}")
foreach(_mod ${DEPENDS})
message(STATUS "mod=${_mod} ${_mod}_PROCESSED=${${_mod}_PROCESSED}|")
......@@ -349,7 +345,6 @@ macro(dune_project)
"${SUGGESTS_MODULE}" "${SUGGESTS_VERSION}")
message(STATUS "DEPENDENCY_TREE=${DEPENDENCY_TREE}")
message("DUNE_LIBS=${DUNE_LIBS}")
# Search for cmake files containing tests and directives
# specific to this module
dune_module_to_macro(_macro ${DUNE_MOD_NAME})
......@@ -414,17 +409,10 @@ macro(finalize_dune_project)
configure_file(
${PROJECT_SOURCE_DIR}/cmake/pkg/${DUNE_MOD_NAME}-config.cmake.in
${PROJECT_BINARY_DIR}/cmake/pkg/${DUNE_MOD_NAME}-config.cmake @ONLY)
message(DEPENDS_MODULE=${DEPENDS_MODULE})
list(LENGTH DEPENDS_MODULE mlength)
#if(mlength GREATER 0)
math(EXPR len2 "${mlength}-1")
#else(mlength GREATER 0)
#endif(mlength GREATER 0)
message(mlength=${mlength})
message(length=${len2})
math(EXPR len2 "${mlength}-1")
if(mlength GREATER 0)
foreach(i RANGE 0 ${len2})
message("i=${i}")
list(GET DEPENDS_MODULE ${i} _mod)
dune_module_to_macro(_macro ${_mod})
list(GET DEPENDS_VERSION ${i} _ver)
......@@ -463,7 +451,7 @@ macro(finalize_dune_project)
export(PACKAGE ${DUNE_MOD_NAME})
if("${ARGC}" EQUAL "1")
message("Adding custom target for config.h generation")
message(STATUS "Adding custom target for config.h generation")
dune_regenerate_config_cmake()
# add a target to generate config.h.cmake
add_custom_target(OUTPUT config.h.cmake
......@@ -474,7 +462,7 @@ macro(finalize_dune_project)
configure_file(${CMAKE_CURRENT_BINARY_DIR}/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)
else("${ARGC}" EQUAL "1")
message("Not adding custom target for config.h generation")
message(STATUS "Not adding custom target for config.h generation")
# actually write the config.h file to disk
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
endif("${ARGC}" EQUAL "1")
......@@ -483,9 +471,7 @@ macro(finalize_dune_project)
endmacro(finalize_dune_project)
macro(target_link_dune_default_libraries _target)
message("libs ${DUNE_DEFAULT_LIBS}")
foreach(_lib ${DUNE_DEFAULT_LIBS})
message("lib=${_lib}")
target_link_libraries(${_target} ${_lib})
endforeach(_lib ${DUNE_DEFAULT_LIBS})
endmacro(target_link_dune_default_libraries)
......@@ -515,7 +501,6 @@ macro(dune_add_library basename)
cmake_parse_arguments(DUNE_LIB "NO_EXPORT" "COMPILE_FLAGS"
"ADD_LIBS;SOURCES" ${ARGN})
#create lib
message("add_library(${basename} ${DUNE_SOURCES} ${DUNE_LIB_UNPARSED_ARGUMENTS})")
add_library(${basename} ${DUNE_SOURCES} ${DUNE_LIB_UNPARSED_ARGUMENTS})
# link with specified libraries.
if(DUNE_LIB_ADD_LIBS)
......@@ -580,6 +565,48 @@ macro(dune_add_library basename)
endif(NOT DUNE_LIB_NO_EXPORT)
endmacro(dune_add_library basename sources)
macro(replace_properties_for_one)
get_property(properties ${option_command} ${_target}
PROPERTY ${REPLACE_PROPERTY})
if(NOT properties)
# property not set. set it directly
foreach(i RANGE 0 ${hlength})
math(EXPR idx "(2 * ${i}) + 1")
list(GET REPLACE_UNPARSED_ARGUMENTS ${idx} repl)
list(APPEND replacement ${repl})
endforeach(i RANGE 0 ${hlength})
list(REMOVE_DUPLICATES replacement)
message(STATUS "properties not yet set. Setting ${replacement} ...")
set_property(${option_command} ${_target} ${REPLACE_APPEND}
${REPLACE_APPEND_STRING} PROPERTY ${REPLACE_PROPERTY} ${replacement})
else(NOT properties)
foreach(prop ${properties})
set(matched FALSE)
foreach(i RANGE 0 ${hlength})
math(EXPR regexi "2 * ${i}")
math(EXPR repli "${regexi} +1")
list(GET REPLACE_UNPARSED_ARGUMENTS ${regexi} regex)
list(GET REPLACE_UNPARSED_ARGUMENTS ${repli} replacement)
string(REGEX MATCH ${regex} match ${prop})
if(match)
list(APPEND new_props ${replacement})
set(matched TRUE)
endif(match)
endforeach(i RANGE 0 ${hlength})
if(NOT matched)
list(APPEND new_props ${prop})
endif(NOT matched)
endforeach(prop ${properties})
list(REMOVE_DUPLICATES new_props)
set_property(${option_command} ${_target}
PROPERTY ${REPLACE_PROPERTY} ${new_props})
endif(NOT properties)
get_property(properties ${option_command} ${_target} PROPERTY ${REPLACE_PROPERTY})
message(STATUS "new properties are ${properties}")
endmacro(replace_properties_for_one)
function(dune_target_link_libraries basename libraries)
target_link_libraries(${basename} ${libraries})
if(DUNE_BUILD_BOTH_LIBS)
......@@ -591,11 +618,11 @@ function(dune_target_link_libraries basename libraries)
endif(DUNE_BUILD_BOTH_LIBS)
endfunction(dune_target_link_libraries basename libraries)
function(replace_current_dir_properties)
function(replace_properties)
include(CMakeParseArguments)
set(_first_opts "GLOBAL;DIRECTORY;TARGET;SOURCES;CACHE")
set(_first_opts "GLOBAL;DIRECTORY;TARGET;SOURCE;CACHE")
cmake_parse_arguments(REPLACE "GLOBAL"
"DIRECTORY;PROPERTY" "TARGET;SOURCES;TEST;CACHE" ${ARGN})
"DIRECTORY;PROPERTY" "TARGET;SOURCE;TEST;CACHE" ${ARGN})
set(MY_DIRECTORY TRUE)
foreach(i ${_first_opts})
......@@ -619,7 +646,6 @@ function(replace_current_dir_properties)
set(option_command GLOBAL)
elseif(MY_DIRECTORY)
set(option_command DIRECTORY)
message("DIR=${CMAKE_CURRENT_SOURCE_DIR}")
elseif(REPLACE_DIRECTORY)
set(option_command DIRECTORY)
set(option_arg ${REPLACE_DIRECTORY})
......@@ -627,7 +653,7 @@ function(replace_current_dir_properties)
set(option_command TARGET)
set(option_arg ${REPLACE_TARGET})
elseif(REPLACE_SOURCE)
set(option_comand SOURCE)
set(option_command SOURCE)
set(option_arg ${REPLACE_SOURCE})
elseif(REPLACE_TEST)
set(option_command TEST)
......@@ -635,12 +661,15 @@ function(replace_current_dir_properties)
elseif(REPLACE_CACHE)
set(option_command CACHE)
set(option_arg ${REPLACE_CACHE})
else()
endif()
if(NOT (REPLACE_CACHE OR REPLACE_TEST OR REPLACE_SOURCE
OR REPLACE_TARGET OR REPLACE_DIRECTORY OR REPLACE_GLOBAL
OR MY_DIRECTORY))
message(ERROR "One of GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, or CACHE"
" has to be present")
endif()
message("${option_command} ${option_arg} REPLACE_UNPARSED_ARGUMENTS=${REPLACE_UNPARSED_ARGUMENTS}")
list(LENGTH REPLACE_UNPARSED_ARGUMENTS length)
# if(NOT (REPLACE_GLOBAL AND REPLACE_TARGET AND
# REPLACE_SOURCE AND REPLACE
......@@ -656,47 +685,12 @@ function(replace_current_dir_properties)
and a replacement string. ${REPLACE_UNPARSED_ARGUMENTS}")
endif(NOT length GREATER 0)
message("get_property(properties ${option_command} ${option_arg} PROPERTY ${REPLACE_PROPERTY})")
get_property(properties ${option_command} ${option_arg}
PROPERTY ${REPLACE_PROPERTY})
message(STATUS " old property ${option_command} ${option_arg}: ${properties}")
if(NOT properties)
# property not set. set it directly
foreach(i RANGE 0 ${hlength})
math(EXPR idx "(2 * ${i}) + 1")
list(GET REPLACE_UNPARSED_ARGUMENTS ${idx} repl)
list(APPEND replacement ${repl})
endforeach(i RANGE 0 ${hlength})
message("hlength=${hlength} replacement=${replacemnt}")
list(REMOVE_DUPLICATES replacement)
message(STATUS "properties not yet set. Setting ${replacement} ...")
set_property(${option_command} ${option_arg} ${REPLACE_APPEND}
${REPLACE_APPEND_STRING} PROPERTY ${REPLACE_PROPERTY} ${replacement})
return()
endif(NOT properties)
foreach(prop ${properties})
set(matched FALSE)
foreach(i RANGE 0 ${hlength})
math(EXPR regexi "2 * ${i}")
math(EXPR repli "${regexi} +1")
list(GET REPLACE_UNPARSED_ARGUMENTS ${regexi} regex)
list(GET REPLACE_UNPARSED_ARGUMENTS ${repli} replacement)
string(REGEX MATCH ${regex} match ${prop})
if(match)
list(APPEND new_props ${replacement})
set(matched TRUE)
endif(match)
endforeach(i RANGE 0 ${hlength})
foreach(_target ${option_arg})
replace_properties_for_one()
endforeach(_target ${option_arg})
if(NOT matched)
list(APPEND new_props ${prop})
endif(NOT matched)
endforeach(prop ${properties})
set_property(${option_command} ${option_arg}
PROPERTY ${REPLACE_PROPERTY} ${new_props})
message("setting prop ${option_command} ${option_arg}
PROPERTY ${REPLACE_PROPERTY} ${new_props}")
get_property(properties ${option_command} ${option_arg} PROPERTY ${REPLACE_PROPERTY})
message(STATUS "new properties are ${properties}")
endfunction(replace_current_dir_properties)
list(LENGTH option_arg _length)
if(_length EQUAL 0)
replace_properties_for_one()
endif(_length EQUAL 0)
endfunction(replace_properties)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment