-
Notifications
You must be signed in to change notification settings - Fork 159
/
CMakeLists.txt
69 lines (57 loc) · 2.17 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.27)
project(libmonome VERSION 1.4.8)
set(CMAKE_C_STANDARD 17)
include(GNUInstallDirs)
set(libmonome_sources
src/libmonome.c
src/monobright.c
src/rotation.c
src/proto/40h.c
src/proto/mext.c
src/proto/series.c
src/platform/embed.c)
set(libmonome_libs)
if(LINUX)
include(FindPkgConfig)
pkg_check_modules(libudev REQUIRED IMPORTED_TARGET libudev)
list(APPEND libmonome_sources
src/platform/linux_libudev.c
src/platform/linux.c
src/platform/posix.c)
list(APPEND libmonome_libs PkgConfig::libudev)
endif()
if(APPLE)
list(APPEND libmonome_sources
src/platform/darwin.c
src/platform/posix.c)
endif()
if(WIN32)
list(APPEND libmonome_sources src/platform/windows.c)
list(APPEND libmonome_libs setupapi)
endif()
add_library(monome_static STATIC ${libmonome_sources})
set_target_properties(monome_static PROPERTIES OUTPUT_NAME "monome")
target_compile_definitions(monome_static PRIVATE EMBED_PROTOS)
target_include_directories(monome_static PRIVATE src/private)
target_include_directories(monome_static PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/public>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(monome_static PRIVATE ${libmonome_libs})
if(NOT MSVC)
target_compile_options(monome_static PRIVATE -Wall -Werror -Wno-initializer-overrides)
endif()
add_library(monome SHARED ${libmonome_sources})
target_compile_definitions(monome PRIVATE EMBED_PROTOS)
target_include_directories(monome PRIVATE src/private)
target_include_directories(monome PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/public>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(monome PRIVATE ${libmonome_libs})
if(NOT MSVC)
target_compile_options(monome PRIVATE -Wall -Werror -Wno-initializer-overrides)
endif()
install(TARGETS monome_static monome EXPORT libmonomeConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT libmonomeConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libmonome NAMESPACE libmonome::)
install(DIRECTORY public/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})