Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
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
Container Registry
Model registry
Operate
Environments
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
Daniel Black
CMake
Commits
98e6d1e5
Commit
98e6d1e5
authored
8 years ago
by
Rolf Eike Beer
Browse files
Options
Downloads
Patches
Plain Diff
Tests/Module/WCDH: make it work with only C features defined
parent
c8703e9d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+51
-51
51 additions, 51 deletions
Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
with
51 additions
and
51 deletions
Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+
51
−
51
View file @
98e6d1e5
...
...
@@ -20,7 +20,57 @@ write_compiler_detection_header(
${
cxx_known_features
}
${
c_known_features
}
)
if
(
NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES
)
macro
(
set_defines target true_defs false_defs
)
set
(
defines
)
foreach
(
def
${
true_defs
}
)
list
(
APPEND defines
${
def
}
=1
)
endforeach
()
foreach
(
def
${
false_defs
}
)
list
(
APPEND defines
${
def
}
=0
)
endforeach
()
target_compile_definitions
(
${
target
}
PRIVATE
${
defines
}
EXPECTED_COMPILER_VERSION_MAJOR=
${
COMPILER_VERSION_MAJOR
}
EXPECTED_COMPILER_VERSION_MINOR=
${
COMPILER_VERSION_MINOR
}
EXPECTED_COMPILER_VERSION_PATCH=
${
COMPILER_VERSION_PATCH
}
)
endmacro
()
if
(
CMAKE_C_COMPILE_FEATURES
)
string
(
REGEX REPLACE
"^([0-9]+)
\\
.[0-9]+
\\
.[0-9]+.*"
"
\\
1"
COMPILER_VERSION_MAJOR
"
${
CMAKE_C_COMPILER_VERSION
}
"
)
string
(
REGEX REPLACE
"^[0-9]+
\\
.([0-9]+)
\\
.[0-9]+.*"
"
\\
1"
COMPILER_VERSION_MINOR
"
${
CMAKE_C_COMPILER_VERSION
}
"
)
string
(
REGEX REPLACE
"^[0-9]+
\\
.[0-9]+
\\
.([0-9]+).*"
"
\\
1"
COMPILER_VERSION_PATCH
"
${
CMAKE_C_COMPILER_VERSION
}
"
)
if
(
CMAKE_C_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_C_COMPILER_ID STREQUAL
"Clang"
OR CMAKE_C_COMPILER_ID STREQUAL
"AppleClang"
OR CMAKE_C_COMPILER_ID STREQUAL
"Intel"
)
add_executable
(
WriteCompilerDetectionHeader_C11 main.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C11 PROPERTY C_STANDARD 11
)
set_defines
(
WriteCompilerDetectionHeader_C11
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT"
""
)
add_executable
(
WriteCompilerDetectionHeader_C11_multi main_multi.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C11_multi PROPERTY C_STANDARD 11
)
set_defines
(
WriteCompilerDetectionHeader_C11_multi
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT"
""
)
target_include_directories
(
WriteCompilerDetectionHeader_C11_multi PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
/compiler_multi_files
)
add_executable
(
C_undefined c_undefined.c
)
set_property
(
TARGET C_undefined PROPERTY C_STANDARD 90
)
target_compile_options
(
C_undefined PRIVATE -Werror=undef
)
add_executable
(
WriteCompilerDetectionHeader_C main.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C PROPERTY C_STANDARD 90
)
set_defines
(
WriteCompilerDetectionHeader_C
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES"
"EXPECTED_COMPILER_C_RESTRICT"
)
add_executable
(
WriteCompilerDetectionHeader_C_multi main_multi.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C_multi PROPERTY C_STANDARD 90
)
set_defines
(
WriteCompilerDetectionHeader_C_multi
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES"
"EXPECTED_COMPILER_C_RESTRICT"
)
target_include_directories
(
WriteCompilerDetectionHeader_C_multi PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
/compiler_multi_files
)
endif
()
endif
()
if
(
NOT CMAKE_CXX_COMPILE_FEATURES
)
file
(
WRITE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/dummy.cpp"
"int main(int,char**) { return 0; }
\n
"
)
...
...
@@ -41,23 +91,6 @@ string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJO
string
(
REGEX REPLACE
"^[0-9]+
\\
.([0-9]+)
\\
.[0-9]+.*"
"
\\
1"
COMPILER_VERSION_MINOR
"
${
CMAKE_CXX_COMPILER_VERSION
}
"
)
string
(
REGEX REPLACE
"^[0-9]+
\\
.[0-9]+
\\
.([0-9]+).*"
"
\\
1"
COMPILER_VERSION_PATCH
"
${
CMAKE_CXX_COMPILER_VERSION
}
"
)
macro
(
set_defines target true_defs false_defs
)
set
(
defines
)
foreach
(
def
${
true_defs
}
)
list
(
APPEND defines
${
def
}
=1
)
endforeach
()
foreach
(
def
${
false_defs
}
)
list
(
APPEND defines
${
def
}
=0
)
endforeach
()
target_compile_definitions
(
${
target
}
PRIVATE
${
defines
}
EXPECTED_COMPILER_VERSION_MAJOR=
${
COMPILER_VERSION_MAJOR
}
EXPECTED_COMPILER_VERSION_MINOR=
${
COMPILER_VERSION_MINOR
}
EXPECTED_COMPILER_VERSION_PATCH=
${
COMPILER_VERSION_PATCH
}
)
endmacro
()
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
OR CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
...
...
@@ -79,25 +112,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif
()
endif
()
if
(
CMAKE_C_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_C_COMPILER_ID STREQUAL
"Clang"
OR CMAKE_C_COMPILER_ID STREQUAL
"AppleClang"
OR CMAKE_C_COMPILER_ID STREQUAL
"Intel"
)
add_executable
(
C_undefined c_undefined.c
)
set_property
(
TARGET C_undefined PROPERTY C_STANDARD 90
)
target_compile_options
(
C_undefined PRIVATE -Werror=undef
)
add_executable
(
WriteCompilerDetectionHeader_C main.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C PROPERTY C_STANDARD 90
)
set_defines
(
WriteCompilerDetectionHeader_C
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES"
"EXPECTED_COMPILER_C_RESTRICT"
)
add_executable
(
WriteCompilerDetectionHeader_C_multi main_multi.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C_multi PROPERTY C_STANDARD 90
)
set_defines
(
WriteCompilerDetectionHeader_C_multi
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES"
"EXPECTED_COMPILER_C_RESTRICT"
)
target_include_directories
(
WriteCompilerDetectionHeader_C_multi PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
/compiler_multi_files
)
endif
()
add_executable
(
WriteCompilerDetectionHeader main.cpp
)
set_property
(
TARGET WriteCompilerDetectionHeader PROPERTY CXX_STANDARD 98
)
set_defines
(
WriteCompilerDetectionHeader
"
${
true_defs
}
"
"
${
false_defs
}
"
)
...
...
@@ -143,20 +157,6 @@ set_property(TARGET multi_files_11 PROPERTY CXX_STANDARD 11)
target_include_directories
(
multi_files_11 PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
/compiler_multi_files
)
set_defines
(
multi_files_11
"
${
true_defs
}
"
"
${
false_defs
}
"
)
if
(
CMAKE_C_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_C_COMPILER_ID STREQUAL
"Clang"
OR CMAKE_C_COMPILER_ID STREQUAL
"AppleClang"
OR CMAKE_C_COMPILER_ID STREQUAL
"Intel"
)
add_executable
(
WriteCompilerDetectionHeader_C11 main.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C11 PROPERTY C_STANDARD 11
)
set_defines
(
WriteCompilerDetectionHeader_C11
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT"
""
)
add_executable
(
WriteCompilerDetectionHeader_C11_multi main_multi.c
)
set_property
(
TARGET WriteCompilerDetectionHeader_C11_multi PROPERTY C_STANDARD 11
)
set_defines
(
WriteCompilerDetectionHeader_C11_multi
"EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT"
""
)
target_include_directories
(
WriteCompilerDetectionHeader_C11_multi PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
/compiler_multi_files
)
endif
()
# test for ALLOW_UNKNOWN_COMPILERS
# use a compiler does not match the current one,
...
...
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