daily pastebin goal
41%
SHARE
TWEET

cmake-config.txt

randUser Jun 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #========================================================================
  2. #
  3. # cmake-config.txt
  4. #
  5. # CMake script to do misc cmake config and platform-specific config.
  6. #
  7. # Copyright 2015 Glyph & Cog, LLC
  8. #
  9. #========================================================================
  10.  
  11. include(CheckFunctionExists)
  12. include(CheckCXXSourceCompiles)
  13.  
  14. enable_language(CXX)
  15.  
  16. #--- set default C/C++ compiler flags for Unix
  17. #    and add a 'Profiling' build mode
  18. if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
  19.   if (CYGWIN)
  20.     set(PIC_FLAG "")
  21.   else ()
  22.     set(PIC_FLAG "-fPIC")
  23.   endif ()
  24.   set(CMAKE_C_FLAGS_DEBUG "-g -O -Wall ${PIC_FLAG}")
  25.   set(CMAKE_CXX_FLAGS_DEBUG "-g -O -Wall ${PIC_FLAG}")
  26.   set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g -O -Wall ${PIC_FLAG}")
  27.   set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall ${PIC_FLAG}")
  28.   set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall ${PIC_FLAG}")
  29.   set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-O2 -Wall ${PIC_FLAG}")
  30.   set(CMAKE_C_FLAGS_PROFILING "-g -pg -O -Wall ${PIC_FLAG}"
  31.       CACHE STRING "C compiler flags for profiling mode")
  32.   set(CMAKE_CXX_FLAGS_PROFILING "-g -pg -O -Wall ${PIC_FLAG}"
  33.       CACHE STRING "C++ compiler flags for profiling mode")
  34.   set(CMAKE_EXE_LINKER_FLAGS_PROFILING "-g -pg -O -Wall ${PIC_FLAG}"
  35.       CACHE STRING "linker flags for profiling mode")
  36.   mark_as_advanced(
  37.     CMAKE_C_FLAGS_PROFILING
  38.     CMAKE_CXX_FLAGS_PROFILING
  39.     CMAKE_EXE_LINKER_FLAGS_PROFILING)
  40.   set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
  41.       "Choose build mode - options are: None Debug Release RelWithDebInfo MinSiz
  42. eRel Profiling")
  43. endif ()
  44.  
  45. #--- set default C/C++ compiler flags for Windows
  46. if (WIN32)
  47.   foreach (var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
  48.                CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
  49.                CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
  50.                CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
  51.     # note: this converts /MD to /MT and /MDd to /MTd
  52.     string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
  53.   endforeach ()
  54.   set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
  55.   set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
  56.   foreach (var CMAKE_C_FLAGS_DEBUG
  57.                CMAKE_C_FLAGS_RELEASE
  58.                CMAKE_C_FLAGS_MINSIZEREL
  59.                CMAKE_C_FLAGS_RELWITHDEBINFO)
  60.     set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996")
  61.   endforeach ()
  62.   foreach (var CMAKE_CXX_FLAGS_DEBUG
  63.                CMAKE_CXX_FLAGS_RELEASE
  64.                CMAKE_CXX_FLAGS_MINSIZEREL
  65.                CMAKE_CXX_FLAGS_RELWITHDEBINFO)
  66.     set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996 /EHsc")
  67.   endforeach ()
  68. endif ()
  69.  
  70. #--- don't set an rpath
  71. set(CMAKE_SKIP_RPATH FALSE)
  72.  
  73. #--- miscellaneous options
  74. option(A4_PAPER "use A4 (instead of Letter) paper size by default for PostScript output" OFF)
  75. option(NO_TEXT_SELECT "do not allow text selection" OFF)
  76. option(OPI_SUPPORT "include support for OPI comments" OFF)
  77. option(MULTITHREADED "include support for multithreading" ON)
  78. option(USE_EXCEPTIONS "use C++ exceptions" ON)
  79. option(USE_FIXEDPOINT "use fixed point (instead of floating point) arithmetic" OFF)
  80. option(SPLASH_CMYK "include support for CMYK rasterization" OFF)
  81. option(SPLASH_DEVICEN "include support for DeviceN rasterization" OFF)
  82. if (SPLASH_DEVICEN)
  83.   set(SPLASH_CMYK ON)
  84. endif ()
  85. option(USE_LCMS "enable color management using lcms2" OFF)
  86. option(HIGHLIGHTED_REGIONS "include support for highlighted regions" OFF)
  87. option(SYSTEM_XPDFRC "full path for system-wide xpdfrc file" "")
  88. if (SYSTEM_XPDFRC)
  89.   set(SYSTEM_XPDFRC_DEFINE "#define SYSTEM_XPDFRC \"${SYSTEM_XPDFRC}\"")
  90. else ()
  91.   set(SYSTEM_XPDFRC_DEFINE "/* #undef SYSTEM_XPDFRC */")
  92. endif ()
  93. option(XPDFWIDGET_PRINTING "include printing support in XpdfWidget" OFF)
  94. option(EVAL_MODE "enable evaluation mode" OFF)
  95. option(BUILDING_XPDFREADER "enable closed source XpdfReader build" OFF)
  96.  
  97. #--- check for various library functions
  98. check_function_exists(mkstemp HAVE_MKSTEMP)
  99. check_function_exists(mkstemps HAVE_MKSTEMPS)
  100. check_function_exists(popen HAVE_POPEN)
  101. check_cxx_source_compiles(
  102.     "#include <algorithm>
  103.     bool cmp(const int &x, const int &y) { return x < y; }
  104.     int a[100];
  105.     int main() { std::sort(a, a+100, &cmp); }"
  106.   HAVE_STD_SORT)
  107.  
  108. #--- set up 64-bit file seeks
  109. check_function_exists(fseeko HAVE_FSEEKO)
  110. check_function_exists(fseek64 HAVE_FSEEK64)
  111. check_function_exists(_fseeki64 HAVE_FSEEKI64)
  112.  
  113. #--- look for FreeType
  114. # This could use cmake's FindFreetype, except that it would require
  115. # a newer version of cmake -- because FreeType changed their include
  116. # paths around.  Older versions of FreeType require two separate
  117. # -I switches (typically ..../include and ..../include/freetype2);
  118. # while newer versions require just one (typically ..../include/freetype2)
  119. find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
  120.   HINTS
  121.   ${FREETYPE_DIR}
  122.   PATHS
  123.   /usr/local/include
  124.   /usr/local/X11R6/include
  125.   /usr/local/X11/include
  126.   /usr/freeware/include
  127.   PATH_SUFFIXES freetype2 include/freetype2 include
  128. )
  129. find_path(FREETYPE_INCLUDE_DIR_freetype freetype.h
  130.   HINTS
  131.   ${FREETYPE_DIR}
  132.   PATHS
  133.   /usr/local/include
  134.   /usr/local/X11R6/include
  135.   /usr/local/X11/include
  136.   /usr/freeware/include
  137.   PATH_SUFFIXES freetype2 include/freetype2 include
  138. )
  139. find_path(FREETYPE_INCLUDE_DIR_freetype_freetype freetype/freetype.h
  140.   HINTS
  141.   ${FREETYPE_DIR}
  142.   PATHS
  143.   /usr/local/include
  144.   /usr/local/X11R6/include
  145.   /usr/local/X11/include
  146.   /usr/freeware/include
  147.   PATH_SUFFIXES freetype2 include/freetype2 include
  148. )
  149. find_library(FREETYPE_LIBRARY
  150.   NAMES freetype libfreetype freetype2 freetype219
  151.   HINTS
  152.   ${FREETYPE_DIR}
  153.   PATH_SUFFIXES lib64 lib
  154.   PATHS
  155.   /usr/local
  156.   /usr/local/X11R6
  157.   /usr/local/X11
  158.   /usr/freeware
  159. )
  160. if (FREETYPE_INCLUDE_DIR_ft2build
  161.     AND FREETYPE_INCLUDE_DIR_freetype
  162.     AND (FREETYPE_INCLUDE_DIR_ft2build STREQUAL FREETYPE_INCLUDE_DIR_freetype)
  163.     AND FREETYPE_LIBRARY)
  164.   set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build}")
  165.   set(HAVE_FREETYPE_H TRUE)
  166.   message(STATUS "Found FreeType (new-style includes): ${FREETYPE_LIBRARY}")
  167. elseif (FREETYPE_INCLUDE_DIR_ft2build
  168.         AND FREETYPE_INCLUDE_DIR_freetype_freetype
  169.         AND FREETYPE_LIBRARY)
  170.   set(FREETYPE_INCLUDE_DIRS
  171.       "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype_freetype}")
  172.   set(HAVE_FREETYPE_H TRUE)
  173.   message(STATUS "Found FreeType (old-style includes): ${FREETYPE_LIBRARY}")
  174. else ()
  175.   message(STATUS "FreeType not found")
  176. endif ()
  177. if (HAVE_FREETYPE_H)
  178.   set(HAVE_SPLASH TRUE)
  179. endif ()
  180.  
  181. #--- look for D-Type
  182. if (DTYPE_INCLUDE_DIR AND DTYPE_LIBRARY)
  183.   set(HAVE_DTYPE4_H TRUE)
  184.   message(STATUS "Found D-Type: ${DTYPE_LIBRARY}")
  185. endif ()
  186.  
  187. #--- look for zlib
  188. find_package(ZLIB)
  189.  
  190. #--- look for libpng
  191. find_package(PNG)
  192.  
  193. #--- look for libjpeg
  194. find_package(JPEG)
  195.  
  196. #--- look for libtiff
  197. find_package(TIFF)
  198.  
  199. #--- look for lcms2
  200. if (USE_LCMS)
  201.   find_path(LCMS_INCLUDE_DIR lcms2.h
  202.     HINTS
  203.     ${LCMS_DIR}
  204.     PATHS
  205.     /usr/local/include
  206.     /usr/freeware/include
  207.     PATH_SUFFIXES include
  208.   )
  209.   find_library(LCMS_LIBRARY
  210.     NAMES lcms2 liblcms2
  211.     HINTS
  212.     ${LCMS_DIR}
  213.     PATHS
  214.     /usr/local
  215.     /usr/freeware
  216.   )
  217. endif ()
  218. if (USE_LCMS AND LCMS_INCLUDE_DIR AND LCMS_LIBRARY)
  219.   set(HAVE_LCMS TRUE)
  220.   message(STATUS "Found lcms2: ${LCMS_LIBRARY}")
  221. else ()
  222.   set(HAVE_LCMS FALSE)
  223.   message(STATUS "lcms2 not found")
  224. endif ()
  225.  
  226. #--- look for Qt
  227. find_package(Qt5Widgets QUIET)
  228. if (Qt5Widgets_FOUND)
  229.   find_package(Qt5PrintSupport)
  230. else ()
  231.   find_package(Qt4)
  232. endif ()
  233. if(Qt5Widgets_FOUND)
  234.   message(STATUS "Qt5 found")
  235.   if (XPDFWIDGET_PRINTING)
  236.     set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS}")
  237.     set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS}")
  238.     if (APPLE)
  239.       set(QT_LIBRARIES Qt5::Widgets Qt5::PrintSupport "-framework ApplicationServices")
  240.     elseif (UNIX)
  241.       set(QT_LIBRARIES Qt5::Widgets Qt5::PrintSupport cups)
  242.     else ()
  243.       set(QT_LIBRARIES Qt5::Widgets Qt5::PrintSupport)
  244.     endif ()
  245.   else ()
  246.     set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
  247.     set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS}")
  248.     set(QT_LIBRARIES Qt5::Widgets)
  249.   endif ()
  250.   if (XPDFWIDGET_PRINTING)
  251.     if (APPLE)
  252.       set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
  253.     elseif (UNIX)
  254.       set(EXTRA_QT_LIBRARIES cups)
  255.     else ()
  256.       set(EXTRA_QT_LIBRARIES "")
  257.     endif ()
  258.   endif ()
  259.   # remove "-fPIE" here because we added "-fPIC" above
  260.   string(REPLACE "-fPIE" "" QT_CFLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
  261.   if (POLICY CMP0020)
  262.     # do not link to qtmain.lib
  263.     cmake_policy(SET CMP0020 OLD)
  264.   endif ()
  265. elseif(QT4_FOUND)
  266.   message(STATUS "Qt4 found")
  267.   if (XPDFWIDGET_PRINTING)
  268.     if (APPLE)
  269.       set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
  270.     elseif (UNIX)
  271.       set(EXTRA_QT_LIBRARIES cups)
  272.     else ()
  273.       set(EXTRA_QT_LIBRARIES "")
  274.     endif ()
  275.   endif ()
  276. else()
  277.   message(STATUS "No Qt library found")
  278. endif()
  279.  
  280. #--- look for libpaper
  281. find_library(HAVE_PAPER_H
  282.              NAMES paper libpaper
  283.              PATH_SUFFIXES lib64 lib
  284. )
  285.  
  286. #--- look for pthreads
  287. find_package(Threads)
  288.  
  289. #--- create aconf.h
  290. configure_file("aconf.h.in" "aconf.h")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top