cmakelists 常见用法

x33g5p2x  于2022-03-03 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(333)

头文件,库文件:

cmake 头文件 库文件_jacke121的专栏-CSDN博客_cmake 头文件

error: ‘__declspec‘ attributes are not enabled; use ‘-fdeclspec‘ or ‘-fms-extensions‘ to enabl

error: ‘__declspec‘ attributes are not enabled; use ‘-fdeclspec‘ or ‘-fms-extensions‘ to enabl_jacke121的专栏-CSDN博客

常见参数:

set(CPU_OPTIONS "${CPU_OPTIONS} -mthumb -mcpu=cortex-m0")
 
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CPU_OPTIONS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPU_OPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-use-cxa-atexit")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
 
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${LINKER_SCRIPT}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostartfiles")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
 
# optimizations (-O0 -O1 -O2 -O3 -Os -Ofast -Og -flto)
set(OPTIMIZATION_DEBUG "-Og")
set(OPTIMIZATION_RELEASE "-O2 -flto")
 
set(CMAKE_C_FLAGS_DEBUG "${OPTIMIZATION_DEBUG} -g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${OPTIMIZATION_DEBUG} -g -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${OPTIMIZATION_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${OPTIMIZATION_RELEASE}")

相关文章