Skip to content

Commit e24c44f

Browse files
committed
Sync flags for Clang and GNU compiler
In Autotools, the GCC variable is set to "yes" when there is GNU-compatible compiler detected. Than includes Clang. This refactors some compile options and definitions a bit further.
1 parent 79a4c35 commit e24c44f

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,11 @@ endif()
787787

788788
# Check GCOV.
789789
if(PHP_GCOV)
790-
if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
791-
message(FATAL_ERROR "GCC is required for using PHP_GCOV='ON'.")
790+
if(NOT CMAKE_C_COMPILER_ID MATCHES "^(.*Clang|GNU)$")
791+
message(
792+
FATAL_ERROR
793+
"GNU-compatible compiler is required for using PHP_GCOV='ON'."
794+
)
792795
endif()
793796

794797
if(CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")

cmake/cmake/Flags.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ include(PHP/CheckCompilerFlag)
1010

1111
get_property(enabledLanguages GLOBAL PROPERTY ENABLED_LANGUAGES)
1212

13+
# See https://bugs.php.net/28605.
14+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
15+
if(CMAKE_C_COMPILER_ID MATCHES "^(.*Clang|GNU)$")
16+
target_compile_options(php_config INTERFACE $<$<COMPILE_LANGUAGE:C>:-mieee>)
17+
else()
18+
target_compile_options(php_config INTERFACE $<$<COMPILE_LANGUAGE:C>:-ieee>)
19+
endif()
20+
endif()
21+
1322
# Check for broken GCC optimize-strlen.
1423
include(PHP/CheckBrokenGccStrlenOpt)
1524
if(PHP_HAVE_BROKEN_OPTIMIZE_STRLEN)

cmake/cmake/Platform.cmake

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,6 @@ include(GNUInstallDirs)
2424
# Detect C standard library implementation.
2525
include(PHP/StandardLibrary)
2626

27-
# See https://bugs.php.net/28605.
28-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
29-
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
30-
target_compile_options(
31-
php_config
32-
INTERFACE
33-
$<$<COMPILE_LANGUAGE:ASM,C>:-mieee>
34-
)
35-
else()
36-
target_compile_options(
37-
php_config
38-
INTERFACE
39-
$<$<COMPILE_LANGUAGE:ASM,C>:-ieee>
40-
)
41-
endif()
42-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
43-
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
44-
target_compile_options(
45-
php_config
46-
INTERFACE
47-
$<$<COMPILE_LANGUAGE:ASM,C>:-xmemalign=8s>
48-
)
49-
endif()
50-
endif()
51-
5227
# Platform-specific configuration. When cross-compiling, the host and target can
5328
# be different values with different configurations.
5429
if(NOT CMAKE_HOST_SYSTEM_NAME EQUAL CMAKE_SYSTEM_NAME)

cmake/cmake/platforms/HP-UX.cmake

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ Specific configuration for HP-UX platform.
55
include_guard(GLOBAL)
66

77
if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
8-
target_compile_definitions(
9-
php_config
10-
INTERFACE
11-
$<$<COMPILE_LANG_AND_ID:ASM,GNU>:_XOPEN_SOURCE_EXTENDED>
12-
$<$<COMPILE_LANG_AND_ID:C,GNU>:_XOPEN_SOURCE_EXTENDED>
13-
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:_XOPEN_SOURCE_EXTENDED>
14-
)
8+
if(CMAKE_C_COMPILER_ID MATCHES "^(.*Clang|GNU)$")
9+
target_compile_definitions(
10+
php_config
11+
INTERFACE $<$<COMPILE_LANGUAGE:C>:_XOPEN_SOURCE_EXTENDED>
12+
)
13+
endif()
14+
15+
if(CMAKE_CXX_COMPILER_ID MATCHES "^(.*Clang|GNU)$")
16+
target_compile_definitions(
17+
php_config
18+
INTERFACE $<$<COMPILE_LANGUAGE:CXX>:_XOPEN_SOURCE_EXTENDED>
19+
)
20+
endif()
1521
endif()

0 commit comments

Comments
 (0)