Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-common
Commits
6b6970ad
Commit
6b6970ad
authored
12 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Use functions instead of macros.
Allow replacement of all possible properties. [[Imported from SVN: r6912]]
parent
6290397d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmake/modules/DuneMacros.cmake
+57
-22
57 additions, 22 deletions
cmake/modules/DuneMacros.cmake
with
57 additions
and
22 deletions
cmake/modules/DuneMacros.cmake
+
57
−
22
View file @
6b6970ad
...
...
@@ -580,7 +580,7 @@ macro(dune_add_library basename)
endif
(
NOT DUNE_LIB_NO_EXPORT
)
endmacro
(
dune_add_library basename sources
)
macro
(
dune_target_link_libraries basename libraries
)
function
(
dune_target_link_libraries basename libraries
)
target_link_libraries
(
${
basename
}
${
libraries
}
)
if
(
DUNE_BUILD_BOTH_LIBS
)
if
(
BUILD_SHARED_LIBS
)
...
...
@@ -589,30 +589,40 @@ macro(dune_target_link_libraries basename libraries)
target_link_libraries
(
${
basename
}
-shared
${
libraries
}
)
endif
(
BUILD_SHARED_LIBS
)
endif
(
DUNE_BUILD_BOTH_LIBS
)
end
macro
(
dune_target_link_libraries basename libraries
)
end
function
(
dune_target_link_libraries basename libraries
)
macro
(
replace_current_dir_properties
)
function
(
replace_current_dir_properties
)
include
(
CMakeParseArguments
)
#cmake_parse_arguments(REPLACE "GLOBAL;"
# "" "TARGET;SOURCE;TEST;CACHE;PROPERTY" ${ARGN})
cmake_parse_arguments
(
REPLACE
""
"PROPERTY"
"TARGET;SOURCE;TEST;CACHE"
${
ARGN
}
)
set
(
REPLACE_DIRECTORY TRUE
)
list
(
LENGTH REPLACE_UNPARSED_ARGUMENTS length
)
# if(NOT (REPLACE_GLOBAL AND REPLACE_TARGET AND
# REPLACE_SOURCE AND REPLACE
math
(
EXPR mlength
"
${
length
}
% 2 "
)
math
(
EXPR hlength
"
${
length
}
/ 2 - 1"
)
if
(
NOT
${
mlength
}
EQUAL 0
)
message
(
ERROR
"You need to specify pairs consisting of a regular expression and a replacement string."
)
endif
(
NOT
${
mlength
}
EQUAL 0
)
set
(
_first_opts
"GLOBAL;DIRECTORY;TARGET;SOURCES;CACHE"
)
cmake_parse_arguments
(
REPLACE
"GLOBAL"
"DIRECTORY;PROPERTY"
"TARGET;SOURCES;TEST;CACHE"
${
ARGN
}
)
set
(
MY_DIRECTORY TRUE
)
foreach
(
i
${
_first_opts
}
)
if
(
REPLACE_
${
i
}
)
set
(
MY_DIRECTORY FALSE
)
endif
(
REPLACE_
${
i
}
)
endforeach
(
i
${
_first_opts
}
)
if
(
NOT MY_DIRECTORY
)
list
(
FIND REPLACE_UNPARSED_ARGUMENTS DIRECTORY _found
)
if
(
_found GREATER -1
)
list
(
REMOVE_AT REPLACE_UNPARSED_ARGUMENTS
${
_found
}
)
set
(
MY_DIRECTORY TRUE
)
set
(
REPLACE_DIRECTORY
""
)
endif
(
_found GREATER -1
)
else
(
NOT MY_DIRECTORY
)
#set(REPLACE_PROPERTY
endif
(
NOT MY_DIRECTORY
)
#setup options
if
(
REPLACE_GLOBAL
)
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
}
)
elseif
(
REPLACE_TARGET
)
set
(
option_command TARGET
)
set
(
option_arg
${
REPLACE_TARGET
}
)
...
...
@@ -630,17 +640,40 @@ macro(replace_current_dir_properties)
" 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
math
(
EXPR mlength
"
${
length
}
% 2 "
)
math
(
EXPR hlength
"
${
length
}
/ 2 - 1"
)
if
(
NOT
${
mlength
}
EQUAL 0
)
message
(
ERROR
"You need to specify pairs consisting of a regular expression and a replacement string."
)
endif
(
NOT
${
mlength
}
EQUAL 0
)
get_property
(
properties
${
option_command
}
${
option_arg
}
PROPERTY
${
REPLACE_PROPERTY
}
)
if
(
NOT length GREATER 0
)
message
(
ERROR
"You need to specify at least on pair consisting of a regular expression
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
message
(
STATUS
"properties not yet set. Setting..."
)
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_PROPERY
}
${
replacement
}
)
${
REPLACE_APPEND_STRING
}
PROPERTY
${
REPLACE_PROPER
T
Y
}
${
replacement
}
)
return
()
endif
(
NOT properties
)
message
(
STATUS
"old properties are
${
properties
}
"
)
foreach
(
prop
${
properties
}
)
set
(
matched FALSE
)
foreach
(
i RANGE 0
${
hlength
}
)
...
...
@@ -662,6 +695,8 @@ macro(replace_current_dir_properties)
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
}
"
)
end
macro
(
replace_current_dir_properties
)
end
function
(
replace_current_dir_properties
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment