-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
94 lines (82 loc) · 1.96 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 3.8)
project(input_lite)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_EXAMPLE "Build example" ON)
option(BUILD_SHARED_LIBS "Build shared library" OFF)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
endif()
if(WIN32)
set(INPUT_LITE_PLATFORM_SRC
src/windows/Input.cpp
)
set(INPUT_LITE_PLATFORM_INC
include/windows
)
elseif(APPLE)
set(INPUT_LITE_PLATFORM_SRC
src/ios/Input.cpp
)
set(INPUT_LITE_PLATFORM_INC
include/ios
)
else()
set(INPUT_LITE_PLATFORM_SRC
src/linux/Input.cpp
)
find_package(X11 REQUIRED)
set(INPUT_LITE_PLATFORM_INC
include/linux
${X11_INCLUDE_DIR}
)
endif()
include_directories(
include
${INPUT_LITE_PLATFORM_INC}
)
add_library(${PROJECT_NAME}
include/Input_Lite.h
src/InputManager.cpp
src/Input_Lite.cpp
${INPUT_LITE_PLATFORM_SRC}
)
if(${BUILD_SHARED_LIBS})
set_target_properties(${PROJECT_NAME} PROPERTIES DEFINE_SYMBOL INPUT_LITE_DLL)
if(APPLE)
find_package(Threads REQUIRED)
find_library(corefoundation_lib CoreFoundation)
find_library(cocoa_lib Cocoa)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} ${corefoundation_lib} ${cocoa_lib})
else()
find_package(X11 REQUIRED)
if(!X11_XTest_FOUND)
message(FATAL_ERROR "X11 extensions are required, but not found!")
endif()
if(!X11_Xfixes_LIB)
message(FATAL_ERROR "X11 fixes extension is required, but not found!")
endif()
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME}
${X11_LIBRARIES}
${X11_Xfixes_LIB}
${X11_XTest_LIB}
${CMAKE_THREAD_LIBS_INIT}
)
endif()
endif()
install (TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install (FILES
include/Input_Lite.h
DESTINATION include
)
if(BUILD_EXAMPLE)
add_subdirectory(Test)
endif()