1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 05:26:58 +08:00

Modules:Check,GenerateExportHeader: include only what's needed

GenerateExportHeader had a hidden state requirement that other
modules were included first. Considering include_guard, Modules
should include all they actually use.
This commit is contained in:
scivision
2023-03-09 22:08:45 -05:00
parent 7d43bcb4db
commit 03c6ebf2b5
8 changed files with 17 additions and 23 deletions

View File

@@ -33,7 +33,6 @@ effect or even a specific one is beyond the scope of this module.
#]=======================================================================] #]=======================================================================]
include_guard(GLOBAL) include_guard(GLOBAL)
include(CheckCSourceCompiles)
include(Internal/CheckCompilerFlag) include(Internal/CheckCompilerFlag)
macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT) macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT)

View File

@@ -33,7 +33,6 @@ effect or even a specific one is beyond the scope of this module.
#]=======================================================================] #]=======================================================================]
include_guard(GLOBAL) include_guard(GLOBAL)
include(CheckCXXSourceCompiles)
include(Internal/CheckCompilerFlag) include(Internal/CheckCompilerFlag)
macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)

View File

@@ -35,7 +35,6 @@ effect or even a specific one is beyond the scope of this module.
#]=======================================================================] #]=======================================================================]
include_guard(GLOBAL) include_guard(GLOBAL)
include(CheckFortranSourceCompiles)
include(Internal/CheckCompilerFlag) include(Internal/CheckCompilerFlag)
macro (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT) macro (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT)

View File

@@ -35,7 +35,6 @@ effect or even a specific one is beyond the scope of this module.
#]=======================================================================] #]=======================================================================]
include_guard(GLOBAL) include_guard(GLOBAL)
include(CheckOBJCSourceCompiles)
include(Internal/CheckCompilerFlag) include(Internal/CheckCompilerFlag)
macro (CHECK_OBJC_COMPILER_FLAG _FLAG _RESULT) macro (CHECK_OBJC_COMPILER_FLAG _FLAG _RESULT)

View File

@@ -35,7 +35,6 @@ effect or even a specific one is beyond the scope of this module.
#]=======================================================================] #]=======================================================================]
include_guard(GLOBAL) include_guard(GLOBAL)
include(CheckOBJCXXSourceCompiles)
include(Internal/CheckCompilerFlag) include(Internal/CheckCompilerFlag)
macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT) macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT)

View File

@@ -51,8 +51,7 @@ Example:
#]=======================================================================] #]=======================================================================]
include_guard(GLOBAL) include_guard(GLOBAL)
include(CheckCSourceCompiles) include(CheckSourceCompiles)
include(CheckCXXSourceCompiles)
macro (CHECK_STRUCT_HAS_MEMBER _STRUCT _MEMBER _HEADER _RESULT) macro (CHECK_STRUCT_HAS_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
set(_INCLUDE_FILES) set(_INCLUDE_FILES)
@@ -78,9 +77,9 @@ int main()
") ")
if("${_lang}" STREQUAL "C") if("${_lang}" STREQUAL "C")
CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) CHECK_SOURCE_COMPILES(C "${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
elseif("${_lang}" STREQUAL "CXX") elseif("${_lang}" STREQUAL "CXX")
CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) CHECK_SOURCE_COMPILES(CXX "${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
else() else()
message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n") message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n")
endif() endif()

View File

@@ -6,11 +6,11 @@ project(FortranCInterface C Fortran)
include(${FortranCInterface_BINARY_DIR}/Input.cmake OPTIONAL) include(${FortranCInterface_BINARY_DIR}/Input.cmake OPTIONAL)
# Check if the C compiler supports '$' in identifiers. # Check if the C compiler supports '$' in identifiers.
include(CheckCSourceCompiles) include(CheckSourceCompiles)
check_c_source_compiles(" check_source_compiles(C
extern int dollar$(void); "extern int dollar$(void);
int main() { return 0; } int main() { return 0; }"
" C_SUPPORTS_DOLLAR) C_SUPPORTS_DOLLAR)
# List manglings of global symbol names to try. # List manglings of global symbol names to try.
set(global_symbols set(global_symbols

View File

@@ -198,19 +198,19 @@ that will be populated with the ``CXX_FLAGS`` required to enable visibility
support for the compiler/architecture in use. support for the compiler/architecture in use.
#]=======================================================================] #]=======================================================================]
include(CheckCCompilerFlag) include(CheckCompilerFlag)
include(CheckCXXCompilerFlag) include(CheckSourceCompiles)
# TODO: Install this macro separately? # TODO: Install this macro separately?
macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT) macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT)
check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } check_source_compiles(CXX "${_ATTRIBUTE} int somefunc() { return 0; }
int main() { return somefunc();}" ${_RESULT} int main() { return somefunc();}" ${_RESULT}
) )
endmacro() endmacro()
# TODO: Install this macro separately? # TODO: Install this macro separately?
macro(_check_c_compiler_attribute _ATTRIBUTE _RESULT) macro(_check_c_compiler_attribute _ATTRIBUTE _RESULT)
check_c_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } check_source_compiles(C "${_ATTRIBUTE} int somefunc() { return 0; }
int main() { return somefunc();}" ${_RESULT} int main() { return somefunc();}" ${_RESULT}
) )
endmacro() endmacro()
@@ -226,7 +226,7 @@ macro(_test_compiler_hidden_visibility)
endif() endif()
# Exclude XL here because it misinterprets -fvisibility=hidden even though # Exclude XL here because it misinterprets -fvisibility=hidden even though
# the check_cxx_compiler_flag passes # the check_compiler_flag passes
if(NOT GCC_TOO_OLD if(NOT GCC_TOO_OLD
AND NOT _INTEL_TOO_OLD AND NOT _INTEL_TOO_OLD
AND NOT WIN32 AND NOT WIN32
@@ -235,12 +235,12 @@ macro(_test_compiler_hidden_visibility)
AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^(PGI|NVHPC)$" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^(PGI|NVHPC)$"
AND NOT CMAKE_CXX_COMPILER_ID MATCHES Watcom) AND NOT CMAKE_CXX_COMPILER_ID MATCHES Watcom)
if (CMAKE_CXX_COMPILER_LOADED) if (CMAKE_CXX_COMPILER_LOADED)
check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_compiler_flag(CXX -fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
check_cxx_compiler_flag(-fvisibility-inlines-hidden check_compiler_flag(CXX -fvisibility-inlines-hidden
COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) COMPILER_HAS_HIDDEN_INLINE_VISIBILITY)
else() else()
check_c_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_compiler_flag(C -fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
check_c_compiler_flag(-fvisibility-inlines-hidden check_compiler_flag(C -fvisibility-inlines-hidden
COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) COMPILER_HAS_HIDDEN_INLINE_VISIBILITY)
endif() endif()
endif() endif()