forked from mheily/libpwq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (82 loc) · 2.38 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
#
# Copyright (c) 2011 Marius Zwicker <marius@mlba-team.de>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
cmake_minimum_required(VERSION 2.8)
INCLUDE (CheckIncludeFiles)
project(pthread_workqueue)
#files
file(GLOB_RECURSE INCL include/*.h)
source_group(includes FILES ${INCL})
if(WIN32)
file(GLOB SRC
src/windows/*.h
src/windows/*.c
src/*.h
src/*.c
)
add_definitions(
-DLIBPTHREAD_WORKQUEUE_EXPORTS
-D_USRDLL
-D_WINDLL
)
else()
file(GLOB UNIX_SRC
src/posix/*.h
src/posix/*.c
src/*.h
src/*.c
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
file(GLOB LINUX_SRC src/linux/*.c)
SET(SRC ${UNIX_SRC} ${LINUX_SRC})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
file(GLOB SOLARIS_SRC src/solaris/*.c)
SET(SRC ${UNIX_SRC} ${SOLARIS_SRC})
endif()
include_directories(
src
)
add_definitions(
-DHAVE_ERR_H=1
-D_XOPEN_SOURCE=600
-D_GNU_SOURCE
-std=c99
-fPIC
)
endif()
source_group(src FILES ${SRC})
#includes
include_directories(
include
)
#library (static or shared)
option(STATIC_WORKQUEUE "Enable to build libpthread_workqueue as static lib" OFF)
if(STATIC_WORKQUEUE)
message("-- building libpthread_workqueue as static lib")
add_definitions(-DMAKE_STATIC)
add_library(pthread_workqueue STATIC ${SRC} ${INCL})
else()
add_library(pthread_workqueue SHARED ${SRC} ${INCL})
endif()
if(NOT WIN32)
target_link_libraries(pthread_workqueue pthread)
endif()
set_target_properties(pthread_workqueue PROPERTIES DEBUG_POSTFIX "D")
#tests
option(WORKQUEUE_TESTS "Enable to build tests for libpthread_workqueue" OFF)
if(WORKQUEUE_TESTS)
message("-- Adding tests for libpthread_workqueue")
add_subdirectory(testing)
endif()