Home | History | Annotate | Download | only in libdivsufsort
      1 ### cmake file for building libdivsufsort Package ###
      2 cmake_minimum_required(VERSION 2.4.4)
      3 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
      4 include(AppendCompilerFlags)
      5 
      6 ## Project information ##
      7 project(libdivsufsort C)
      8 set(PROJECT_VENDOR "Yuta Mori")
      9 set(PROJECT_CONTACT "yuta.256 (at] gmail.com")
     10 set(PROJECT_URL "https://github.com/y-256/libdivsufsort")
     11 set(PROJECT_DESCRIPTION "A lightweight suffix sorting library")
     12 include(VERSION.cmake)
     13 
     14 ## CPack configuration ##
     15 set(CPACK_GENERATOR "TGZ;TBZ2;ZIP")
     16 set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2;ZIP")
     17 include(ProjectCPack)
     18 
     19 ## Project options ##
     20 option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
     21 option(BUILD_EXAMPLES "Build examples" ON)
     22 option(BUILD_DIVSUFSORT64 "Build libdivsufsort64" OFF)
     23 option(USE_OPENMP "Use OpenMP for parallelization" OFF)
     24 option(WITH_LFS "Enable Large File Support" ON)
     25 
     26 ## Installation directories ##
     27 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32 or 64)")
     28 
     29 set(CMAKE_INSTALL_RUNTIMEDIR "" CACHE PATH "Specify the output directory for dll runtimes (default is bin)")
     30 if(NOT CMAKE_INSTALL_RUNTIMEDIR)
     31   set(CMAKE_INSTALL_RUNTIMEDIR "${CMAKE_INSTALL_PREFIX}/bin")
     32 endif(NOT CMAKE_INSTALL_RUNTIMEDIR)
     33 
     34 set(CMAKE_INSTALL_LIBDIR "" CACHE PATH "Specify the output directory for libraries (default is lib)")
     35 if(NOT CMAKE_INSTALL_LIBDIR)
     36   set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
     37 endif(NOT CMAKE_INSTALL_LIBDIR)
     38 
     39 set(CMAKE_INSTALL_INCLUDEDIR "" CACHE PATH "Specify the output directory for header files (default is include)")
     40 if(NOT CMAKE_INSTALL_INCLUDEDIR)
     41   set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
     42 endif(NOT CMAKE_INSTALL_INCLUDEDIR)
     43 
     44 set(CMAKE_INSTALL_PKGCONFIGDIR "" CACHE PATH "Specify the output directory for pkgconfig files (default is lib/pkgconfig)")
     45 if(NOT CMAKE_INSTALL_PKGCONFIGDIR)
     46   set(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
     47 endif(NOT CMAKE_INSTALL_PKGCONFIGDIR)
     48 
     49 ## Build type ##
     50 if(NOT CMAKE_BUILD_TYPE)
     51   set(CMAKE_BUILD_TYPE "Release")
     52 elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
     53   set(CMAKE_VERBOSE_MAKEFILE ON)
     54 endif(NOT CMAKE_BUILD_TYPE)
     55 
     56 ## Compiler options ##
     57 if(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)
     63 elseif(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)
     66 else(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)
     80 endif(MSVC)
     81 
     82 ## Add definitions ##
     83 add_definitions(-DHAVE_CONFIG_H=1 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS)
     84 
     85 ## Add subdirectories ##
     86 add_subdirectory(pkgconfig)
     87 add_subdirectory(include)
     88 add_subdirectory(lib)
     89 if(BUILD_EXAMPLES)
     90   add_subdirectory(examples)
     91 endif(BUILD_EXAMPLES)
     92 
     93 ## Add 'uninstall' target ##
     94 CONFIGURE_FILE(
     95   "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
     96   "${CMAKE_CURRENT_BINARY_DIR}/CMakeModules/cmake_uninstall.cmake"
     97   IMMEDIATE @ONLY)
     98 ADD_CUSTOM_TARGET(uninstall
     99   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/CMakeModules/cmake_uninstall.cmake")
    100