File: CMakeLists.txt

package info (click to toggle)
dashel 1.3.3-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,208 kB
  • sloc: cpp: 3,196; ansic: 181; makefile: 10
file content (98 lines) | stat: -rw-r--r-- 3,109 bytes parent folder | download
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
94
95
96
97
98
cmake_minimum_required(VERSION 2.6)

project(dashel)

export(PACKAGE dashel)

option(BUILD_SHARED_LIBS "Build shared instead of static libs" ON)

# libudev
find_path(UDEV_INCLUDE_DIR libudev.h)
find_library(UDEV_LIBS udev)

if (UDEV_INCLUDE_DIR AND UDEV_LIBS)
	message(STATUS "libudev found")
	set(UDEV_FOUND 1)
endif (UDEV_INCLUDE_DIR AND UDEV_LIBS)

# libraries
if (WIN32)
	set(DASHEL_SOURCES dashel/dashel-win32.cpp dashel/dashel-common.cpp)
	set(DASHEL_INSTALL_HEADER dashel/dashel.h)
	set(EXTRA_LIBS winspool ws2_32 setupapi)
else (WIN32)
	set(DASHEL_SOURCES dashel/dashel-posix.cpp dashel/dashel-common.cpp)
	set(DASHEL_INSTALL_HEADER dashel/dashel.h dashel/dashel-posix.h)
	if (APPLE)
		set(DASHEL_SOURCES ${DASHEL_SOURCES} dashel/poll_emu.c)
		find_library(COREFOUNDATION_LIBRARY CoreFoundation)
		find_library(IOKIT_LIBRARY IOKit)
		mark_as_advanced(COREFOUNDATION_LIBRARY)
		mark_as_advanced(IOKIT_LIBRARY)
		find_library(POLL_LIBRARY poll)
		set(EXTRA_LIBS ${COREFOUNDATION_LIBRARY} ${IOKIT_LIBRARY} ${POLL_LIBRARY})
		set(CMAKE_MACOSX_RPATH ON) # Solve the CMP0042 warning
	else (APPLE)
		if (UDEV_FOUND)
			include_directories(${UDEV_INCLUDE_DIR})
			set(EXTRA_LIBS ${UDEV_LIBS})
			add_definitions(-DUSE_LIBUDEV)
		else (UDEV_FOUND)
			find_package(PkgConfig)
			pkg_check_modules(HAL hal)
			if (${HAL_FOUND})
				include_directories(${HAL_INCLUDE_DIRS})
				set(EXTRA_LIBS ${HAL_LIBRARIES})
				add_definitions(-DUSE_HAL)
			endif (${HAL_FOUND})
		endif (UDEV_FOUND)
	endif (APPLE)
endif (WIN32)

add_library(dashel ${DASHEL_SOURCES})
target_link_libraries(dashel ${EXTRA_LIBS})

# dynamic library version
set(LIB_INSTALL_DIR lib CACHE FILEPATH "Where to install libraries")
set(LIB_VERSION_MAJOR 1) # Must be bumped for incompatible ABI changes
set(LIB_VERSION_MINOR 3)
set(LIB_VERSION_PATCH 3)
set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
set_target_properties(dashel PROPERTIES VERSION ${LIB_VERSION_STRING} 
                                        SOVERSION ${LIB_VERSION_MAJOR})


# generate configure file
configure_file(dashelConfig.cmake.in "${PROJECT_BINARY_DIR}/dashelConfig.cmake" @ONLY)
configure_file(dashelConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/dashelConfigVersion.cmake" @ONLY)
  
# install target
install(FILES ${DASHEL_INSTALL_HEADER}
        DESTINATION include/dashel)
install(TARGETS dashel
        LIBRARY DESTINATION ${LIB_INSTALL_DIR}
        ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
)
if (WIN32 AND NOT CYGWIN)
	set(INSTALL_CMAKE_DIR CMake)
else()
	if (APPLE)
		set(INSTALL_CMAKE_DIR Frameworks/dashel.framework/Resources/CMake/)
	else()
		set(INSTALL_CMAKE_DIR share/dashel/CMake)
	endif()
endif()
install(FILES "${PROJECT_BINARY_DIR}/dashelConfig.cmake"
	DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
install(FILES "${PROJECT_BINARY_DIR}/dashelConfigVersion.cmake"
	DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)


# examples
add_subdirectory(examples)

# test cases
#foreach (test none-for-now)
#	add_executable(${test} tests/${test}.cpp)
#	target_link_libraries(${test} dashel ${EXTRA_LIBS})
#endforeach (test)