23 lines
796 B
CMake
23 lines
796 B
CMake
cmake_minimum_required(VERSION 3.10.0)
|
||
project(ConsoleLib VERSION 0.1.0 LANGUAGES C CXX)
|
||
|
||
option(ConsoleLib_BUILD_EXAMPLES "Build ConsoleLib examples" ON)
|
||
|
||
# 静态库:Linux/macOS 生成 libConsoleLib.a,Windows 生成 ConsoleLib.lib
|
||
add_library(ConsoleLib STATIC ConsoleLib.cpp include/ConsoleLib.hpp)
|
||
|
||
# 共享库:Linux/macOS 生成 libConsoleLib.so,Windows 生成 ConsoleLib.dll
|
||
add_library(ConsoleLib_shared SHARED ConsoleLib.cpp)
|
||
|
||
target_include_directories(ConsoleLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||
target_include_directories(ConsoleLib_shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||
|
||
set_target_properties(ConsoleLib_shared PROPERTIES
|
||
OUTPUT_NAME ConsoleLib
|
||
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
||
)
|
||
|
||
if(ConsoleLib_BUILD_EXAMPLES)
|
||
add_subdirectory(example)
|
||
endif()
|