-
Notifications
You must be signed in to change notification settings - Fork 156
/
CMakeLists.txt
79 lines (63 loc) · 2.27 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
cmake_minimum_required(VERSION 3.16)
project(screen_capture_lite_build VERSION 17.1)
set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_EXAMPLE "Build example" ON)
option(BUILD_CSHARP "Build C#" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 -D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
endif()
if(${BUILD_SHARED_LIBS})
set(TARGET_SUFFIX shared)
else()
set(TARGET_SUFFIX static)
endif()
set(TARGET_NAME screen_capture_lite_${TARGET_SUFFIX})
add_subdirectory(src_cpp)
if(${BUILD_CSHARP} AND ${BUILD_SHARED_LIBS})
add_subdirectory(src_csharp)
endif()
install (TARGETS ${TARGET_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
configure_file(modules/${TARGET_NAME}Config.cmake.in ${TARGET_NAME}Config.cmake @ONLY)
#export(TARGETS ${TARGET_NAME} FILE ${TARGET_NAME}-config.cmake)
#install(EXPORT ${TARGET_NAME}-config FILE ${TARGET_NAME}-config.cmake DESTINATION lib/cmake/screen_capture_lite)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Config.cmake
DESTINATION lib${LIB_SUFFIX}/cmake/${TARGET_NAME})
install (FILES
include/ScreenCapture.h
DESTINATION include
)
if (NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
enable_testing()
if (${BUILD_EXAMPLE})
add_subdirectory(Example_OpenGL)
add_subdirectory(Example_CPP)
if(${BUILD_CSHARP} AND ${BUILD_SHARED_LIBS})
add_subdirectory(Example_CSharp)
add_subdirectory(Example_Unity)
endif()
endif()