• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1### cmake file for building libdivsufsort Package ###
2cmake_minimum_required(VERSION 2.4.4)
3set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
4include(AppendCompilerFlags)
5
6## Project information ##
7project(libdivsufsort C)
8set(PROJECT_VENDOR "Yuta Mori")
9set(PROJECT_CONTACT "yuta.256@gmail.com")
10set(PROJECT_URL "https://github.com/y-256/libdivsufsort")
11set(PROJECT_DESCRIPTION "A lightweight suffix sorting library")
12include(VERSION.cmake)
13
14## CPack configuration ##
15set(CPACK_GENERATOR "TGZ;TBZ2;ZIP")
16set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2;ZIP")
17include(ProjectCPack)
18
19## Project options ##
20option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
21option(BUILD_EXAMPLES "Build examples" ON)
22option(BUILD_DIVSUFSORT64 "Build libdivsufsort64" OFF)
23option(USE_OPENMP "Use OpenMP for parallelization" OFF)
24option(WITH_LFS "Enable Large File Support" ON)
25
26## Installation directories ##
27set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32 or 64)")
28
29set(CMAKE_INSTALL_RUNTIMEDIR "" CACHE PATH "Specify the output directory for dll runtimes (default is bin)")
30if(NOT CMAKE_INSTALL_RUNTIMEDIR)
31  set(CMAKE_INSTALL_RUNTIMEDIR "${CMAKE_INSTALL_PREFIX}/bin")
32endif(NOT CMAKE_INSTALL_RUNTIMEDIR)
33
34set(CMAKE_INSTALL_LIBDIR "" CACHE PATH "Specify the output directory for libraries (default is lib)")
35if(NOT CMAKE_INSTALL_LIBDIR)
36  set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
37endif(NOT CMAKE_INSTALL_LIBDIR)
38
39set(CMAKE_INSTALL_INCLUDEDIR "" CACHE PATH "Specify the output directory for header files (default is include)")
40if(NOT CMAKE_INSTALL_INCLUDEDIR)
41  set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
42endif(NOT CMAKE_INSTALL_INCLUDEDIR)
43
44set(CMAKE_INSTALL_PKGCONFIGDIR "" CACHE PATH "Specify the output directory for pkgconfig files (default is lib/pkgconfig)")
45if(NOT CMAKE_INSTALL_PKGCONFIGDIR)
46  set(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
47endif(NOT CMAKE_INSTALL_PKGCONFIGDIR)
48
49## Build type ##
50if(NOT CMAKE_BUILD_TYPE)
51  set(CMAKE_BUILD_TYPE "Release")
52elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
53  set(CMAKE_VERBOSE_MAKEFILE ON)
54endif(NOT CMAKE_BUILD_TYPE)
55
56## Compiler options ##
57if(MSVC)
58  append_c_compiler_flags("/W4" "VC" CMAKE_C_FLAGS)
59  append_c_compiler_flags("/Oi;/Ot;/Ox;/Oy" "VC" CMAKE_C_FLAGS_RELEASE)
60  if(USE_OPENMP)
61    append_c_compiler_flags("/openmp" "VC" CMAKE_C_FLAGS)
62  endif(USE_OPENMP)
63elseif(BORLAND)
64  append_c_compiler_flags("-w" "BCC" CMAKE_C_FLAGS)
65  append_c_compiler_flags("-Oi;-Og;-Os;-Ov;-Ox" "BCC" CMAKE_C_FLAGS_RELEASE)
66else(MSVC)
67  if(CMAKE_COMPILER_IS_GNUCC)
68    append_c_compiler_flags("-Wall" "GCC" CMAKE_C_FLAGS)
69    append_c_compiler_flags("-fomit-frame-pointer" "GCC" CMAKE_C_FLAGS_RELEASE)
70    if(USE_OPENMP)
71      append_c_compiler_flags("-fopenmp" "GCC" CMAKE_C_FLAGS)
72    endif(USE_OPENMP)
73  else(CMAKE_COMPILER_IS_GNUCC)
74    append_c_compiler_flags("-Wall" "UNKNOWN" CMAKE_C_FLAGS)
75    append_c_compiler_flags("-fomit-frame-pointer" "UNKNOWN" CMAKE_C_FLAGS_RELEASE)
76    if(USE_OPENMP)
77      append_c_compiler_flags("-fopenmp;-openmp;-omp" "UNKNOWN" CMAKE_C_FLAGS)
78    endif(USE_OPENMP)
79  endif(CMAKE_COMPILER_IS_GNUCC)
80endif(MSVC)
81
82## Add definitions ##
83add_definitions(-DHAVE_CONFIG_H=1 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS)
84
85## Add subdirectories ##
86add_subdirectory(pkgconfig)
87add_subdirectory(include)
88add_subdirectory(lib)
89if(BUILD_EXAMPLES)
90  add_subdirectory(examples)
91endif(BUILD_EXAMPLES)
92
93## Add 'uninstall' target ##
94CONFIGURE_FILE(
95  "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
96  "${CMAKE_CURRENT_BINARY_DIR}/CMakeModules/cmake_uninstall.cmake"
97  IMMEDIATE @ONLY)
98ADD_CUSTOM_TARGET(uninstall
99  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/CMakeModules/cmake_uninstall.cmake")
100