Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
CMake
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2,683
Issues
2,683
List
Boards
Labels
Milestones
Merge Requests
16
Merge Requests
16
Packages
Packages
Container Registry
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
CMake
CMake
Commits
a27bc0cc
Commit
a27bc0cc
authored
Sep 22, 2015
by
Rolf Eike Beer
Committed by
Brad King
Sep 25, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check(Function|Library|Symbol)Exists: make it work if only C++ is enabled
parent
7279f293
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
5 deletions
+41
-5
Help/release/dev/Threads-CXX.rst
Help/release/dev/Threads-CXX.rst
+6
-0
Modules/CheckFunctionExists.c
Modules/CheckFunctionExists.c
+3
-0
Modules/CheckFunctionExists.cmake
Modules/CheckFunctionExists.cmake
+13
-1
Modules/CheckLibraryExists.cmake
Modules/CheckLibraryExists.cmake
+12
-1
Modules/CheckSymbolExists.cmake
Modules/CheckSymbolExists.cmake
+7
-3
No files found.
Help/release/dev/Threads-CXX.rst
0 → 100644
View file @
a27bc0cc
Threads-CXX
------------
* The :module:`CheckFunctionExists`, :module:`CheckLibraryExists`, and
:module:`CheckSymbolExists` modules learned to work in environments where
only CXX is enabled.
Modules/CheckFunctionExists.c
View file @
a27bc0cc
#ifdef CHECK_FUNCTION_EXISTS
#ifdef __cplusplus
extern
"C"
#endif
char
CHECK_FUNCTION_EXISTS
();
#ifdef __CLASSIC_C__
int
main
(){
...
...
Modules/CheckFunctionExists.cmake
View file @
a27bc0cc
...
...
@@ -57,14 +57,26 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
else
()
set
(
CHECK_FUNCTION_EXISTS_ADD_INCLUDES
)
endif
()
if
(
CMAKE_C_COMPILER_LOADED
)
set
(
_cfe_source
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
)
elseif
(
CMAKE_CXX_COMPILER_LOADED
)
set
(
_cfe_source
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CheckFunctionExists/CheckFunctionExists.cxx
)
configure_file
(
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
"
${
_cfe_source
}
"
COPYONLY
)
else
()
message
(
FATAL_ERROR
"CHECK_FUNCTION_EXISTS needs either C or CXX language enabled"
)
endif
()
try_compile
(
${
VARIABLE
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
${
_cfe_source
}
COMPILE_DEFINITIONS
${
CMAKE_REQUIRED_DEFINITIONS
}
${
CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=
${
MACRO_CHECK_FUNCTION_DEFINITIONS
}
"
${
CHECK_FUNCTION_EXISTS_ADD_INCLUDES
}
"
OUTPUT_VARIABLE OUTPUT
)
unset
(
_cfe_source
)
if
(
${
VARIABLE
}
)
set
(
${
VARIABLE
}
1 CACHE INTERNAL
"Have function
${
FUNCTION
}
"
)
if
(
NOT CMAKE_REQUIRED_QUIET
)
...
...
Modules/CheckLibraryExists.cmake
View file @
a27bc0cc
...
...
@@ -53,15 +53,26 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
set
(
CHECK_LIBRARY_EXISTS_LIBRARIES
${
CHECK_LIBRARY_EXISTS_LIBRARIES
}
${
CMAKE_REQUIRED_LIBRARIES
}
)
endif
()
if
(
CMAKE_C_COMPILER_LOADED
)
set
(
_cle_source
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
)
elseif
(
CMAKE_CXX_COMPILER_LOADED
)
set
(
_cle_source
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CheckLibraryExists/CheckFunctionExists.cxx
)
configure_file
(
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
"
${
_cle_source
}
"
COPYONLY
)
else
()
message
(
FATAL_ERROR
"CHECK_FUNCTION_EXISTS needs either C or CXX language enabled"
)
endif
()
try_compile
(
${
VARIABLE
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
${
_cle_source
}
COMPILE_DEFINITIONS
${
CMAKE_REQUIRED_DEFINITIONS
}
LINK_LIBRARIES
${
CHECK_LIBRARY_EXISTS_LIBRARIES
}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=
${
MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
}
-DLINK_DIRECTORIES:STRING=
${
LOCATION
}
OUTPUT_VARIABLE OUTPUT
)
unset
(
_cle_source
)
if
(
${
VARIABLE
}
)
if
(
NOT CMAKE_REQUIRED_QUIET
)
...
...
Modules/CheckSymbolExists.cmake
View file @
a27bc0cc
...
...
@@ -44,10 +44,14 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
macro
(
CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE
)
_CHECK_SYMBOL_EXISTS
(
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeTmp/CheckSymbolExists.c"
"
${
SYMBOL
}
"
"
${
FILES
}
"
"
${
VARIABLE
}
"
)
if
(
CMAKE_C_COMPILER_LOADED
)
_CHECK_SYMBOL_EXISTS
(
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeTmp/CheckSymbolExists.c"
"
${
SYMBOL
}
"
"
${
FILES
}
"
"
${
VARIABLE
}
"
)
elseif
(
CMAKE_CXX_COMPILER_LOADED
)
_CHECK_SYMBOL_EXISTS
(
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeTmp/CheckSymbolExists.cxx"
"
${
SYMBOL
}
"
"
${
FILES
}
"
"
${
VARIABLE
}
"
)
else
()
message
(
FATAL_ERROR
"CHECK_SYMBOL_EXISTS needs either C or CXX language enabled"
)
endif
()
endmacro
()
macro
(
_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment