Advertisement
Guest User

qjson - CMakeLists.txt

a guest
Mar 1st, 2014
835
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PROJECT(qjson)
  2.  
  3. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII" )
  4.  
  5. # Force cmake 2.8.8 in order to have a decent support of Qt5
  6. CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
  7. CMAKE_POLICY(SET CMP0003 NEW)
  8.  
  9. # Do not link against qtmain on Windows
  10. cmake_policy(SET CMP0020 OLD)
  11.  
  12. set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
  13.  
  14. IF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
  15.   ADD_DEFINITIONS("-DQT_NO_DEBUG_OUTPUT")
  16. ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
  17.  
  18. # Ability to disable verbose debug output
  19. IF(QJSON_VERBOSE_DEBUG_OUTPUT)
  20.   ADD_DEFINITIONS("-DQJSON_VERBOSE_DEBUG_OUTPUT")
  21. endif(QJSON_VERBOSE_DEBUG_OUTPUT)
  22.  
  23. # On Windows debug library should have 'd' postfix.
  24. IF (WIN32)
  25.   SET(CMAKE_DEBUG_POSTFIX "d")
  26. ENDIF (WIN32)
  27.  
  28. OPTION(OSX_FRAMEWORK "Build a Mac OS X Framework")
  29. SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks"
  30.     CACHE PATH "Where to place qjson.framework if OSX_FRAMEWORK is selected")
  31.  
  32. # Don't use absolute path in qjson-targets-*.cmake
  33. # (This will have no effect with CMake < 2.8)
  34. SET(QT_USE_IMPORTED_TARGETS TRUE)
  35.  
  36. option(QT4_BUILD "Force building with Qt4 even if Qt5 is found")
  37. IF (NOT QT4_BUILD)
  38.   FIND_PACKAGE( Qt5Core QUIET )
  39. ENDIF()
  40.  
  41. IF (Qt5Core_FOUND)
  42.   MESSAGE ("Qt5 found")
  43.  
  44.   INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS})
  45.   ADD_DEFINITIONS(${Qt5Core_DEFINITIONS})
  46.  
  47.   # Tell CMake to run moc when necessary:
  48.   set(CMAKE_AUTOMOC ON)
  49.   # As moc files are generated in the binary dir, tell CMake
  50.   # to always look for includes there:
  51.   set(CMAKE_INCLUDE_CURRENT_DIR ON)
  52. ELSE()
  53.   MESSAGE ("Qt5 not found, searching for Qt4)
  54.  # Find Qt4
  55.  FIND_PACKAGE( Qt4 REQUIRED )
  56.  
  57.  # Include the cmake file needed to use qt4
  58.  INCLUDE( ${QT_USE_FILE} )
  59.  
  60. ENDIF()
  61.  
  62. IF (NOT WIN32)
  63.  SET( QT_DONT_USE_QTGUI TRUE )
  64. ENDIF()
  65.  
  66.  
  67. #add extra search paths for libraries and includes
  68. SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
  69. SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Directory where lib will install")
  70. SET (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
  71. SET (CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}" CACHE PATH "Directory where to install QJSONConfig.cmake")
  72.  
  73. set(QJSON_LIB_MAJOR_VERSION "0")
  74. set(QJSON_LIB_MINOR_VERSION "8")
  75. set(QJSON_LIB_PATCH_VERSION "1")
  76.  
  77. set(QJSON_LIB_VERSION_STRING "${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION}")
  78.  
  79. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
  80.  
  81. # pkg-config
  82. IF (NOT WIN32)
  83.  CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/QJson.pc.in
  84.                  ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc
  85.                  @ONLY)
  86.  INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc
  87.           DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
  88. ENDIF (NOT WIN32)
  89.  
  90. # Subdirs
  91. ADD_SUBDIRECTORY(src)
  92. IF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS)
  93.  enable_testing()
  94.  ADD_SUBDIRECTORY(tests)
  95. ENDIF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS)
  96.  
  97. CONFIGURE_FILE(
  98.  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  99.  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  100.  IMMEDIATE @ONLY)
  101.  
  102. INSTALL(EXPORT qjson-export DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE QJSONTargets.cmake)
  103.  
  104. # figure out the relative path from the installed Config.cmake file to the install prefix (which may be at
  105. # runtime different from the chosen CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere)
  106. # This relative path will be configured into the QJSONConfig.cmake
  107. file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX} )
  108.  
  109. # cmake-modules
  110. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfig.cmake.in
  111.               ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake
  112.               @ONLY)
  113. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfigVersion.cmake.in
  114.               ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake
  115.               @ONLY)
  116. INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake
  117.              ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake
  118.        DESTINATION "${CMAKECONFIG_INSTALL_DIR}")
  119.  
  120. ADD_CUSTOM_TARGET(uninstall
  121.  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
Advertisement
RAW Paste Data Copied
Advertisement