-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
77 lines (64 loc) · 2.77 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
# Copyright (C) 2018 ycmd contributors
#
# This file is part of ycmd.
#
# ycmd is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ycmd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ycmd. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required( VERSION 2.8.11 )
project( _regex C )
# Silence the warning about CMake policy CMP0042
set( CMAKE_MACOSX_RPATH ON )
find_package( PythonLibs )
if ( PYTHONLIBS_VERSION_STRING VERSION_LESS "3.0.0" )
set( REGEX_MODULE_DIR ${PROJECT_SOURCE_DIR}/regex_2 )
else()
set( REGEX_MODULE_DIR ${PROJECT_SOURCE_DIR}/regex_3 )
endif()
file( GLOB_RECURSE REGEX_SOURCES ${REGEX_MODULE_DIR}/*.h
${REGEX_MODULE_DIR}/*.c )
include_directories( SYSTEM
${PYTHON_INCLUDE_DIRS} )
add_library( ${PROJECT_NAME} SHARED
${REGEX_SOURCES} )
target_link_libraries( ${PROJECT_NAME}
${PYTHON_LIBRARIES} )
# We don't want the "lib" prefix, it can screw up python when it tries to search
# for our module
set_target_properties( ${PROJECT_NAME} PROPERTIES PREFIX "" )
if ( WIN32 OR CYGWIN OR MSYS )
# DLL platforms put dlls in the RUNTIME_OUTPUT_DIRECTORY
# First for the generic no-config case (e.g. with mingw)
set_target_properties( ${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${REGEX_MODULE_DIR} )
# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set_target_properties( ${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG}
${REGEX_MODULE_DIR} )
endforeach()
if ( WIN32 )
# This is the extension for compiled Python modules on Windows
set_target_properties( ${PROJECT_NAME} PROPERTIES SUFFIX ".pyd")
elseif ( CYGWIN OR MSYS )
# This is the extension for compiled Python modules in Cygwin and msys
set_target_properties( ${PROJECT_NAME} PROPERTIES SUFFIX ".dll")
endif()
else()
# Even on macs, we want a .so extension instead of a .dylib which is what
# cmake would give us by default. Python won't recognize a .dylib as a module,
# but it will recognize a .so
set_target_properties( ${PROJECT_NAME} PROPERTIES SUFFIX ".so")
endif()
set_target_properties( ${PROJECT_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${REGEX_MODULE_DIR} )