CMakeLists.txt
author Alpar Juttner <alpar@cs.elte.hu>
Tue, 22 Mar 2011 20:26:58 +0100
changeset 8 dda9b6665fde
parent 7 c941f748eaa8
permissions -rw-r--r--
Improved install locations
     1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     2 
     3 ## Here comes the name of your project:
     4 
     5 SET(PROJECT_NAME "LEMON-PROJECT-TEMPLATE")
     6 
     7 ## Change 'hg-tip' to the current version number of your project if you wish.
     8 ## Optionally, you can leave it as is and set PROJECT_VERSION from
     9 ## the cmake-gui when you make a release.
    10 ## The last parameter is a help string displayed by CMAKE.
    11 
    12 SET(PROJECT_VERSION "hg-tip"
    13     CACHE STRING "${PROJECT_NAME} version string")
    14 
    15 ## Do not edit this.
    16 PROJECT(${PROJECT_NAME})
    17 
    18 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    19 
    20 IF(UNIX)
    21   SET(INSTALL_BIN_DIR "bin" CACHE STRING
    22     "Subdir for installing the binaries")
    23   SET(INSTALL_DOC_DIR "share/doc/${PROJECT_NAME}"
    24     CACHE STRING
    25     "Subdir for installing the doc")
    26   SET(INSTALL_DATA_DIR "share/data/${PROJECT_NAME}"
    27     CACHE STRING
    28     "Subdir for installing the map data")
    29   SET(INSTALL_EXAMPLES_DIR "share/doc/${PROJECT_NAME}/examples"
    30     CACHE STRING
    31     "Subdir for installing the examples")
    32 ELSE(UNIX)
    33   SET(INSTALL_BIN_DIR "." CACHE STRING
    34                   "Subdir for installing the binaries")
    35   SET(INSTALL_DOC_DIR "doc" CACHE STRING
    36                   "Subdir for installing the doc")
    37   SET(INSTALL_DATA_DIR "data" CACHE STRING
    38                   "Subdir for installing the map data")
    39   SET(INSTALL_EXAMPLES_DIR "examples" CACHE STRING
    40                        "Subdir for installing the examples")
    41 ENDIF(UNIX)
    42 
    43 ## The next part looks for LEMON. Typically, you don't want to modify it.
    44 ##
    45 ## First, it tries to use LEMON as a CMAKE subproject by looking for
    46 ## it in the 'lemon' or 'deps/lemon' subdirectories or in directory
    47 ## given by the LEMON_SOURCE_ROOT_DIR variable.
    48 ## If LEMON isn't there, then CMAKE will try to find an installed
    49 ## version of LEMON. If it is installed at some non-standard place,
    50 ## then you must tell its location in the LEMON_ROOT_DIR CMAKE config
    51 ## variable. (Do not hard code it into your config! Others may keep
    52 ## LEMON at different places.)
    53 
    54 FIND_PATH(LEMON_SOURCE_ROOT_DIR CMakeLists.txt
    55   PATHS ${CMAKE_SOURCE_DIR}/lemon ${CMAKE_SOURCE_DIR}/deps/lemon
    56   NO_DEFAULT_PATH
    57   DOC "Location of LEMON source as a CMAKE subproject")
    58 
    59 IF(EXISTS ${LEMON_SOURCE_ROOT_DIR})
    60   ADD_SUBDIRECTORY(${LEMON_SOURCE_ROOT_DIR} deps/lemon)
    61   SET(LEMON_INCLUDE_DIRS
    62     ${LEMON_SOURCE_ROOT_DIR}
    63     ${CMAKE_BINARY_DIR}/deps/lemon
    64   )
    65   SET(LEMON_LIBRARIES lemon)
    66   UNSET(LEMON_ROOT_DIR CACHE)
    67   UNSET(LEMON_DIR CACHE)
    68   UNSET(LEMON_INCLUDE_DIR CACHE)
    69   UNSET(LEMON_LIBRARY CACHE)
    70 ELSE()
    71   FIND_PACKAGE(LEMON QUIET NO_MODULE)
    72   FIND_PACKAGE(LEMON REQUIRED)
    73 ENDIF()
    74 
    75 ## This line finds doxygen (for document creation)
    76 
    77 FIND_PACKAGE(Doxygen)
    78 
    79 ## These are the include directories used by the compiler.
    80 
    81 INCLUDE_DIRECTORIES(
    82   ${PROJECT_SOURCE_DIR}
    83   ${PROJECT_BINARY_DIR}
    84   ${LEMON_INCLUDE_DIRS}
    85 )
    86 
    87 IF(CMAKE_COMPILER_IS_GNUCXX)
    88   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
    89   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
    90 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
    91 ADD_SUBDIRECTORY(src)
    92 
    93 ## Sometimes MSVC overwhelms you with compiler warnings which are impossible to
    94 ## avoid. Then comment out these sections. Normally you won't need it as the
    95 ## LEMON include headers suppress these warnings anyway.
    96 
    97 #IF(MSVC)
    98 #  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
    99 #      /wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
   100 # # Suppressed warnings:
   101 # # C4250: 'class1' : inherits 'class2::member' via dominance
   102 # # C4355: 'this' : used in base member initializer list
   103 # # C4503: 'function' : decorated name length exceeded, name was truncated
   104 # # C4800: 'type' : forcing value to bool 'true' or 'false'
   105 # #        (performance warning)
   106 # # C4996: 'function': was declared deprecated
   107 # ENDIF(MSVC)
   108 
   109 ENABLE_TESTING()
   110 
   111 ## The auxiliary doxygen files (.dox) should be placed in the 'doc'
   112 ## subdirectory. The next line includes the CMAKE config of that directory.
   113 
   114 ADD_SUBDIRECTORY(doc)
   115 
   116 #######################################################################
   117 ## CPACK configuration
   118 ##
   119 ## It is used to configure the .exe installer created by CPACK.
   120 ## Consider editing these values:
   121 ##
   122 ## - CPACK_PACKAGE_VENDOR
   123 ## - CPACK_PACKAGE_DESCRIPTION_SUMMARY
   124 ## - CPACK_NSIS_HELP_LINK
   125 ## - CPACK_NSIS_URL_INFO_ABOUT
   126 ## - CPACK_NSIS_CONTACT
   127 ##
   128 ## Additionally, you may want to change the icons/images used by the
   129 ## NSIS installer, i.e. these variables:
   130 ##
   131 ## - CPACK_NSIS_MUI_ICON
   132 ## - CPACK_PACKAGE_ICON
   133 ## - CPACK_NSIS_INSTALLED_ICON_NAME
   134 ## 
   135 ## and/or the files they point to.
   136 #######################################################################
   137 
   138 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
   139   SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
   140   SET(CPACK_PACKAGE_VENDOR "EGRES")
   141   SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
   142       "LEMON PROJECT TEMPLATE - A Template Build Environment for LEMON")
   143   SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
   144 
   145   SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
   146 
   147   SET(CPACK_PACKAGE_INSTALL_DIRECTORY
   148       "${PROJECT_NAME}")
   149   SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
   150       "${PROJECT_NAME} ${PROJECT_VERSION}")
   151 
   152   SET(CPACK_COMPONENTS_ALL bin doc)
   153 
   154   SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Executables")
   155   SET(CPACK_COMPONENT_BIN_DESCRIPTION
   156       "Command line utilities")
   157   SET(CPACK_COMPONENT_BIN_REQUIRED TRUE)
   158 
   159   SET(CPACK_COMPONENT_DOC_DISPLAY_NAME "Documentation")
   160   SET(CPACK_COMPONENT_DOC_DESCRIPTION
   161       "Documentation generated by Doxygen.")
   162 
   163     
   164   SET(CPACK_GENERATOR "NSIS")
   165 
   166   SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon-project.ico")
   167   SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
   168   SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
   169   SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon-project.ico")
   170 
   171   SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
   172   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
   173   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
   174   SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
   175   SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
   176       CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
   177       ")
   178   SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
   179       !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
   180       Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
   181       ")
   182 
   183   INCLUDE(CPack)
   184 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})