适配系统适配层的更新
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
if(POLICY CMP0079)
|
||||
cmake_policy(SET CMP0079 NEW)
|
||||
endif()
|
||||
|
||||
project(has_project_host LANGUAGES C)
|
||||
|
||||
# 当前宿主工程通过 add_subdirectory(has_platform) 的方式接入平台子仓库,
|
||||
@@ -8,6 +12,25 @@ project(has_project_host LANGUAGES C)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
add_library(has_project_warnings INTERFACE)
|
||||
|
||||
target_compile_options(has_project_warnings
|
||||
INTERFACE
|
||||
$<$<COMPILE_LANG_AND_ID:C,GNU,Clang,AppleClang>:
|
||||
-Wall
|
||||
-Wextra
|
||||
# -Wpedantic
|
||||
-Wformat=2
|
||||
-Wundef
|
||||
-Wshadow
|
||||
-Wpointer-arith
|
||||
-Wwrite-strings
|
||||
-Wstrict-prototypes
|
||||
# -Wmissing-prototypes
|
||||
-Werror=implicit-function-declaration
|
||||
>
|
||||
)
|
||||
|
||||
# 宿主工程选择如何集成 has_platform:
|
||||
# static: 链接静态库
|
||||
# shared: 链接动态库
|
||||
@@ -44,6 +67,7 @@ else()
|
||||
endif()
|
||||
|
||||
add_subdirectory(has_platform)
|
||||
target_link_libraries(has_platform_obj PRIVATE has_project_warnings)
|
||||
|
||||
# 宿主工程业务源码。保持 has_project 现有目录结构不变。
|
||||
file(GLOB HOST_APP_SOURCES CONFIGURE_DEPENDS
|
||||
@@ -70,6 +94,7 @@ endif()
|
||||
add_executable(test ${HOST_PROJECT_SOURCES})
|
||||
|
||||
target_compile_features(test PRIVATE c_std_11)
|
||||
target_link_libraries(test PRIVATE has_project_warnings)
|
||||
|
||||
# 宿主工程根据选择的模式链接或嵌入 has_platform。
|
||||
if(HAS_PLATFORM_LINK_MODE STREQUAL "static")
|
||||
@@ -87,4 +112,3 @@ set_target_properties(test PROPERTIES
|
||||
)
|
||||
|
||||
message(STATUS "HAS_PLATFORM_LINK_MODE = ${HAS_PLATFORM_LINK_MODE}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user