1
0
forked from Yadciel/c_tray

add cmake support

This commit is contained in:
LonghronShen
2019-05-04 02:45:46 +08:00
committed by Dmitry Mikushin
parent e09fdcf96e
commit 7f190194da
3 changed files with 64 additions and 0 deletions

3
.gitignore vendored
View File

@@ -35,3 +35,6 @@
# Binary # Binary
example example
example.exe example.exe
.vscode/
build/

47
CMakeLists.txt Normal file
View File

@@ -0,0 +1,47 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
#
# Here we check whether mio is being configured in isolation or as a component
# of a larger project. To do so, we query whether the `PROJECT_NAME` CMake
# variable has been defined. In the case it has, we can conclude mio is a
# subproject.
#
# This convention has been borrowed from the Catch C++ unit testing library.
#
if(DEFINED PROJECT_NAME)
set(subproject ON)
else()
set(subproject OFF)
endif()
PROJECT(tray C)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Generate 'compile_commands.json' for clang_complete
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
IF(WIN32)
SET(CMAKE_CXX_FLAGS_RELEASE "/MT")
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
ENDIF()
add_library(tray_base INTERFACE)
target_compile_features(tray_base INTERFACE c_std_99)
if(WIN32)
include(WinApiLevels)
else()
add_library(tray INTERFACE)
target_link_libraries(tray INTERFACE tray_base)
endif()
add_library(tray::tray ALIAS tray)
add_executable(tray_example example.c)
target_link_libraries(tray_example INTERFACE tray_base)
IF(NOT WIN32)
INSTALL(FILES tray.h DESTINATION include)
ENDIF()

14
cmake/WinApiLevels.cmake Normal file
View File

@@ -0,0 +1,14 @@
add_library(tray_full_winapi INTERFACE)
target_link_libraries(tray_full_winapi
INTERFACE tray_base
)
add_library(tray::tray_full_winapi ALIAS tray_full_winapi)
add_library(tray INTERFACE)
target_link_libraries(tray
INTERFACE tray_full_winapi
)
target_compile_definitions(tray
INTERFACE WIN32_LEAN_AND_MEAN NOMINMAX
)
install(TARGETS tray_full_winapi EXPORT trayConfig)