# set minimum cmake version
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# project name and language
project(recipe-04 LANGUAGES CXX)
# define executable and its source file
add_executable(arch-dependent arch-dependent.cpp)
# let the preprocessor know about the size of void *
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(arch-dependent PUBLIC "IS_64_BIT_ARCH")
message(STATUS "Target is 64 bits")
else()
target_compile_definitions(arch-dependent PUBLIC "IS_32_BIT_ARCH")
message(STATUS "Target is 32 bits")
endif()
# let the preprocessor know about the host processor architecture
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i386")
message(STATUS "i386 architecture detected")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i686")
message(STATUS "
cmake 检测处理器体系结构
于 2022-07-28 17:36:53 首次发布
本文介绍了如何在CMake中检测项目的处理器体系结构,这对于跨平台编译和优化至关重要。内容涉及CMake脚本和相关配置,以确保代码正确地针对不同架构进行编译。

最低0.47元/天 解锁文章
9071

被折叠的 条评论
为什么被折叠?



