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
b7fefc74
Commit
b7fefc74
authored
9 years ago
by
Robert K
Browse files
Options
Downloads
Patches
Plain Diff
[Cmake][cleanup] check for necessary unix commands and throw error if not found.
parent
15057f0a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!251
2017-05 merge of upstream repository
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmake/modules/OverloadCompilerFlags.cmake
+41
-12
41 additions, 12 deletions
cmake/modules/OverloadCompilerFlags.cmake
with
41 additions
and
12 deletions
cmake/modules/OverloadCompilerFlags.cmake
+
41
−
12
View file @
b7fefc74
...
...
@@ -22,17 +22,52 @@ if(ALLOW_EXTRA_CXXFLAGS AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*"))
set
(
ALLOW_CXXFLAGS_OVERWRITE ON
)
endif
()
macro
(
find_extended_unix_commands
)
include
(
FindUnixCommands
)
find_program
(
GREP_PROGRAM grep
)
if
(
NOT GREP_PROGRAM
)
message
(
SEND_ERROR
"grep not found, please disable ALLOW_CXXFLAGS_OVERWRITE"
)
endif
()
find_program
(
SED_PROGRAM sed
)
if
(
NOT SED_PROGRAM
)
message
(
SEND_ERROR
"sed not found, please disable ALLOW_CXXFLAGS_OVERWRITE"
)
endif
()
find_program
(
CUT_PROGRAM cut
)
if
(
NOT CUT_PROGRAM
)
message
(
SEND_ERROR
"cut not found, please disable ALLOW_CXXFLAGS_OVERWRITE"
)
endif
()
find_program
(
ENV_PROGRAM env
)
if
(
NOT ENV_PROGRAM
)
message
(
SEND_ERROR
"env not found, please disable ALLOW_CXXFLAGS_OVERWRITE"
)
endif
()
find_program
(
ECHO_PROGRAM echo
)
if
(
NOT ECHO_PROGRAM
)
message
(
SEND_ERROR
"echo not found, please disable ALLOW_CXXFLAGS_OVERWRITE"
)
endif
()
find_program
(
CHMOD_PROGRAM chmod
)
if
(
NOT CHMOD_PROGRAM
)
message
(
SEND_ERROR
"chmod not found, please disable ALLOW_CXXFLAGS_OVERWRITE"
)
endif
()
mark_as_advanced
(
GREP_PROGRAM
)
mark_as_advanced
(
SED_PROGRAM
)
mark_as_advanced
(
CUT_PROGRAM
)
mark_as_advanced
(
ENV_PROGRAM
)
mark_as_advanced
(
ECHO_PROGRAM
)
mark_as_advanced
(
CHMOD_PROGRAM
)
endmacro
(
find_extended_unix_commands
)
# init compiler script and store CXX flags
macro
(
initialize_compiler_script
)
if
(
ALLOW_CXXFLAGS_OVERWRITE
AND
(
${
CMAKE_GENERATOR
}
MATCHES
".*Unix Makefiles.*"
))
find_program
(
BASH_PROGRAM bash
)
# check for unix commands necessary
find_extended_unix_commands
()
# set CXXFLAGS as environment variable
set
(
DEFAULT_CXXFLAGS
${
CMAKE_CXX_FLAGS
}
)
set
(
CMAKE_CXX_FLAGS
""
)
set
(
DEFAULT_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
)
set
(
COMPILER_SCRIPT_FILE
"#!
${
BASH
_PROGRAM
}
\n
exec
${
CMAKE_CXX_COMPILER
}
\"\$
@
\"
"
)
file
(
WRITE
${
CMAKE_BINARY_DIR
}
/compiler.sh
"
${
COMPILER_SCRIPT_FILE
}
"
)
exec_program
(
chmod
ARGS
"+x
${
CMAKE_BINARY_DIR
}
/compiler.sh"
)
set
(
COMPILER_SCRIPT_FILE
"#!
${
BASH
}
\n
exec
${
CMAKE_CXX_COMPILER
}
\"\$
@
\"
"
)
file
(
WRITE
${
CMAKE_BINARY_DIR
}
/compiler.sh
"
${
COMPILER_SCRIPT_FILE
}
"
)
exec_program
(
${
CHMOD_PROGRAM
}
ARGS
"+x
${
CMAKE_BINARY_DIR
}
/compiler.sh"
)
set
(
CMAKE_CXX_COMPILER
${
CMAKE_BINARY_DIR
}
/compiler.sh
)
endif
()
endmacro
()
...
...
@@ -40,12 +75,7 @@ endmacro()
# finalize compiler script and write it
macro
(
finalize_compiler_script
)
if
(
ALLOW_CXXFLAGS_OVERWRITE
AND
(
${
CMAKE_GENERATOR
}
MATCHES
".*Unix Makefiles.*"
))
find_program
(
GREP_PROGRAM grep
)
find_program
(
SED_PROGRAM sed
)
find_program
(
CUT_PROGRAM cut
)
find_program
(
ENV_PROGRAM env
)
find_program
(
ECHO_PROGRAM echo
)
set
(
COMPILER_SCRIPT_FILE
"#!
${
BASH_PROGRAM
}
\n
SED=
${
SED_PROGRAM
}
\n
GREP=
${
GREP_PROGRAM
}
"
)
set
(
COMPILER_SCRIPT_FILE
"#!
${
BASH
}
\n
SED=
${
SED_PROGRAM
}
\n
GREP=
${
GREP_PROGRAM
}
"
)
set
(
COMPILER_SCRIPT_FILE
"
${
COMPILER_SCRIPT_FILE
}
\n
CUT=
${
CUT_PROGRAM
}
\n
ENV=
${
ENV_PROGRAM
}
\n
ECHO=
${
ECHO_PROGRAM
}
"
)
set
(
COMPILER_SCRIPT_FILE
"
${
COMPILER_SCRIPT_FILE
}
\n
# store flags
\n
FLAGS=
\"\$
@
\"
"
)
set
(
COMPILER_SCRIPT_FILE
"
${
COMPILER_SCRIPT_FILE
}
\n
MAKE_EXECUTABLE_NEW=0
\n
"
)
...
...
@@ -63,7 +93,6 @@ macro(finalize_compiler_script)
set
(
COMPILER_SCRIPT_FILE
"
${
COMPILER_SCRIPT_FILE
}
\n
FLAGS=
\"\$
FLAGS
\$
NEWFLAG
\"\n
done"
)
set
(
COMPILER_SCRIPT_FILE
"
${
COMPILER_SCRIPT_FILE
}
\n\$
ECHO
\"
${
DEFAULT_CXX_COMPILER
}
\$
CXXFLAGS
\$
FLAGS
\"
"
)
set
(
COMPILER_SCRIPT_FILE
"
${
COMPILER_SCRIPT_FILE
}
\n
exec
${
DEFAULT_CXX_COMPILER
}
\$
CXXFLAGS
\$
FLAGS"
)
file
(
WRITE
${
CMAKE_BINARY_DIR
}
/compiler.sh
"
${
COMPILER_SCRIPT_FILE
}
"
)
exec_program
(
chmod ARGS
"+x
${
CMAKE_BINARY_DIR
}
/compiler.sh"
)
file
(
WRITE
${
CMAKE_BINARY_DIR
}
/compiler.sh
"
${
COMPILER_SCRIPT_FILE
}
"
)
endif
()
endmacro
()
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