Skip to content

Commit 0d984db

Browse files
committed
fix arch detections in dummy project - affect generating undo-cxx_config.hh
1 parent cf67b59 commit 0d984db

File tree

1 file changed

+65
-34
lines changed

1 file changed

+65
-34
lines changed

cmake/dummy-project.cmake

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,79 @@
1-
2-
31
#
42
# check CPU bits
53
#
64

75
project(dummy
8-
DESCRIPTION "dummy-project for sizeof_void_p detection and more."
9-
LANGUAGES CXX)
10-
if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
11-
# 64 bits
12-
set(CPU_ARCH "x64" CACHE STRING "ARCH x86_64" FORCE)
13-
set(CPU_ARCH_NAME "amd64" CACHE STRING "ARCH x86_64" FORCE)
14-
message(STATUS "x86_64 ...")
15-
elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
16-
# 32 bits
17-
set(CPU_ARCH "x86" CACHE STRING "ARCH x86" FORCE)
18-
set(CPU_ARCH_NAME "x86" CACHE STRING "ARCH x86_64" FORCE)
19-
message(STATUS "x86 (32bit) ...")
20-
else ()
21-
# message(STATUS "Unknown CMAKE_SIZEOF_VOID_P = '${CMAKE_SIZEOF_VOID_P}' ..?")
22-
if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(amd64)|(AMD64)|(x86_64)|(arm64)|(aarch64)")
23-
set(CPU_ARCH "x64" CACHE STRING "ARCH x86_64" FORCE)
24-
#set(CPU_ARCH_NAME "x86_64" CACHE STRING "ARCH x86_64" FORCE)
25-
set(CPU_ARCH_NAME "amd64" CACHE STRING "ARCH x86_64" FORCE)
26-
message(STATUS "x86_64 ...")
27-
else ()
28-
set(CPU_ARCH "x86" CACHE STRING "ARCH x86" FORCE)
29-
set(CPU_ARCH_NAME "x86" CACHE STRING "ARCH x86_64" FORCE)
30-
message(STATUS "x86 (32bit) // '${CMAKE_HOST_SYSTEM_PROCESSOR}' ...")
31-
endif ()
32-
endif ()
6+
DESCRIPTION "dummy-project for sizeof_void_p detection and more."
7+
LANGUAGES CXX)
8+
9+
# if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
10+
# # 64 bits
11+
# set(CPU_ARCH "x64" CACHE STRING "ARCH x86_64" FORCE)
12+
# set(CPU_ARCH_NAME "amd64" CACHE STRING "ARCH x86_64" FORCE)
13+
# message(STATUS "x86_64 ...")
14+
# elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
15+
# # 32 bits
16+
# set(CPU_ARCH "x86" CACHE STRING "ARCH x86" FORCE)
17+
# set(CPU_ARCH_NAME "x86" CACHE STRING "ARCH x86_64" FORCE)
18+
# message(STATUS "x86 (32bit) ...")
19+
# else ()
20+
# # message(STATUS "Unknown CMAKE_SIZEOF_VOID_P = '${CMAKE_SIZEOF_VOID_P}' ..?")
21+
# if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(amd64)|(AMD64)|(x86_64)|(arm64)|(aarch64)")
22+
# set(CPU_ARCH "x64" CACHE STRING "ARCH x86_64" FORCE)
23+
# #set(CPU_ARCH_NAME "x86_64" CACHE STRING "ARCH x86_64" FORCE)
24+
# set(CPU_ARCH_NAME "amd64" CACHE STRING "ARCH x86_64" FORCE)
25+
# message(STATUS "x86_64 ...")
26+
# else ()
27+
# set(CPU_ARCH "x86" CACHE STRING "ARCH x86" FORCE)
28+
# set(CPU_ARCH_NAME "x86" CACHE STRING "ARCH x86_64" FORCE)
29+
# message(STATUS "x86 (32bit) // '${CMAKE_HOST_SYSTEM_PROCESSOR}' ...")
30+
# endif ()
31+
# endif ()
3332

33+
# message(STATUS "Unknown CMAKE_SIZEOF_VOID_P = '${CMAKE_SIZEOF_VOID_P}' ..?")
34+
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(amd64)|(AMD64)|(x86_64)")
35+
set(CPU_ARCH "x64" CACHE STRING "ARCH x86_64" FORCE)
36+
set(CPU_ARCH_BITS "64" CACHE STRING "ARCH x86_64" FORCE)
37+
set(CPU_ARCH_NAME "amd64" CACHE STRING "ARCH x86_64" FORCE)
38+
message(STATUS "dummy > arch: x86_64 ...")
39+
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(arm64)|(aarch64)")
40+
set(CPU_ARCH "x64" CACHE STRING "ARCH aarch64/arm64" FORCE)
41+
set(CPU_ARCH_BITS "64" CACHE STRING "ARCH aarch64/arm64" FORCE)
42+
set(CPU_ARCH_NAME "arm64" CACHE STRING "ARCH aarch64/arm64" FORCE)
43+
message(STATUS "dummy > arch: arm64 ...")
44+
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(arm7)|(armv8)")
45+
set(CPU_ARCH "x32" CACHE STRING "ARCH armv7/armv8" FORCE)
46+
set(CPU_ARCH_BITS "32" CACHE STRING "ARCH armv7/armv8" FORCE)
47+
set(CPU_ARCH_NAME "arm32" CACHE STRING "ARCH arm32" FORCE)
48+
message(STATUS "dummy > arch: arm32 ...")
49+
elseif(${CMAKE_HOST_APPLE})
50+
set(CPU_ARCH_BITS "64" CACHE STRING "ARCH apple x86_64 or arm64" FORCE)
51+
52+
if(${CMAKE_APPLE_SILICON_PROCESSOR} MATCHES "arm64")
53+
set(CPU_ARCH "x64" CACHE STRING "ARCH aarch64/arm64" FORCE)
54+
set(CPU_ARCH_NAME "arm64" CACHE STRING "ARCH aarch64/arm64" FORCE)
55+
message(STATUS "dummy > arch: arm64 ...")
56+
else()
57+
set(CPU_ARCH "x64" CACHE STRING "ARCH x86_64" FORCE)
58+
set(CPU_ARCH_NAME "amd64" CACHE STRING "ARCH x86_64" FORCE)
59+
message(STATUS "dummy > arch: x86_64 ...")
60+
endif()
61+
else()
62+
set(CPU_ARCH "x86" CACHE STRING "ARCH x86" FORCE)
63+
set(CPU_ARCH_BITS "32" CACHE STRING "ARCH x86" FORCE)
64+
set(CPU_ARCH_NAME "x86" CACHE STRING "ARCH x86" FORCE)
65+
message(STATUS "dummy > arch: x86 (32bit) // '${CMAKE_HOST_SYSTEM_PROCESSOR}' ...")
66+
endif()
3467

3568
#
3669
#
3770
#
38-
39-
4071
include(target-dirs)
41-
include(cxx-detect-compilers) # detect cxx compiler
42-
include(detect-systems) # detect OS, ...
43-
include(cxx-macros) # macros: define_cxx_executable_project, ...
44-
include(version-def) # load .version.cmake
45-
include(versions-gen) # generate config.h and version.hh
72+
include(cxx-detect-compilers) # detect cxx compiler
73+
include(detect-systems) # detect OS, ...
74+
include(cxx-macros) # macros: define_cxx_executable_project, ...
75+
include(version-def) # load .version.cmake
76+
include(versions-gen) # generate config.h and version.hh
4677

4778
# when using compiler with cmake multi-config feature, a special build type 'Asan' can be used for sanitizing test.
4879
enable_sanitizer_for_multi_config()

0 commit comments

Comments
 (0)