CMakeLists.txt
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 26 Nov 2010 17:59:31 +0100
changeset 5 723af8fef529
parent 4 6de89926e594
child 7 c941f748eaa8
permissions -rw-r--r--
Configurable LEMON source dir location (when used as a subproject)
     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 ## The next part looks for LEMON. Typically, you don't want to modify it.
    21 ##
    22 ## First, it tries to use LEMON as a CMAKE subproject by looking for
    23 ## it in the 'lemon' or 'deps/lemon' subdirectories or in directory
    24 ## given by the LEMON_SOURCE_ROOT_DIR variable.
    25 ## If LEMON isn't there, then CMAKE will try to find an installed
    26 ## version of LEMON. If it is installed at some non-standard place,
    27 ## then you must tell its location in the LEMON_ROOT_DIR CMAKE config
    28 ## variable. (Do not hard code it into your config! Others may keep
    29 ## LEMON at different places.)
    30 
    31 FIND_PATH(LEMON_SOURCE_ROOT_DIR CMakeLists.txt
    32   PATHS ${CMAKE_SOURCE_DIR}/lemon ${CMAKE_SOURCE_DIR}/deps/lemon
    33   NO_DEFAULT_PATH
    34   DOC "Location of LEMON source as a CMAKE subproject")
    35 
    36 IF(EXISTS ${LEMON_SOURCE_ROOT_DIR})
    37   ADD_SUBDIRECTORY(${LEMON_SOURCE_ROOT_DIR} deps/lemon)
    38   SET(LEMON_INCLUDE_DIRS
    39     ${LEMON_SOURCE_ROOT_DIR}
    40     ${CMAKE_BINARY_DIR}/deps/lemon
    41   )
    42   SET(LEMON_LIBRARIES lemon)
    43   UNSET(LEMON_ROOT_DIR CACHE)
    44   UNSET(LEMON_DIR CACHE)
    45   UNSET(LEMON_INCLUDE_DIR CACHE)
    46   UNSET(LEMON_LIBRARY CACHE)
    47 ELSE()
    48   FIND_PACKAGE(LEMON QUIET NO_MODULE)
    49   FIND_PACKAGE(LEMON REQUIRED)
    50 ENDIF()
    51 
    52 ## This line finds doxygen (for document creation)
    53 
    54 FIND_PACKAGE(Doxygen)
    55 
    56 ## These are the include directories used by the compiler.
    57 
    58 INCLUDE_DIRECTORIES(
    59   ${PROJECT_SOURCE_DIR}
    60   ${PROJECT_BINARY_DIR}
    61   ${LEMON_INCLUDE_DIRS}
    62 )
    63 
    64 ## Here we define an executable target. Its name is 'lemon-project' and
    65 ## is compiled from 'main.cc'. You can add more source files separated
    66 ## with whitespaces (including newlines). If you want to build more
    67 ## executables, simple repeat (and edit) the following ADD_EXECUTABLE and
    68 ## TARGET_LINK_LIBRARIES statements.
    69 
    70 ADD_EXECUTABLE(lemon-project main.cc)
    71 TARGET_LINK_LIBRARIES(lemon-project ${LEMON_LIBRARIES})
    72 
    73 ## This tells cmake to install 'lemon-project' to $PREFIX/bin when
    74 ## 'make install' is executed. You can give more targets separated
    75 ## by whitespaces.
    76 
    77 INSTALL(
    78   TARGETS lemon-project
    79   RUNTIME DESTINATION bin
    80   COMPONENT bin
    81 )
    82 
    83 ## Sometimes MSVC overwhelms you with compiler warnings which are impossible to
    84 ## avoid. Then comment out these sections. Normally you won't need it as the
    85 ## LEMON include headers suppress these warnings anyway.
    86 
    87 #IF(MSVC)
    88 #  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
    89 #      /wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
    90 # # Suppressed warnings:
    91 # # C4250: 'class1' : inherits 'class2::member' via dominance
    92 # # C4355: 'this' : used in base member initializer list
    93 # # C4503: 'function' : decorated name length exceeded, name was truncated
    94 # # C4800: 'type' : forcing value to bool 'true' or 'false'
    95 # #        (performance warning)
    96 # # C4996: 'function': was declared deprecated
    97 # ENDIF(MSVC)
    98 
    99 ENABLE_TESTING()
   100 
   101 ## The auxiliary doxygen files (.dox) should be placed in the 'doc'
   102 ## subdirectory. The next line includes the CMAKE config of that directory.
   103 
   104 ADD_SUBDIRECTORY(doc)
   105 
   106 #######################################################################
   107 ## CPACK configuration
   108 ##
   109 ## It is used to configure the .exe installer created by CPACK.
   110 ## Consider editing these values:
   111 ##
   112 ## - CPACK_PACKAGE_VENDOR
   113 ## - CPACK_PACKAGE_DESCRIPTION_SUMMARY
   114 ## - CPACK_NSIS_HELP_LINK
   115 ## - CPACK_NSIS_URL_INFO_ABOUT
   116 ## - CPACK_NSIS_CONTACT
   117 ##
   118 ## Additionally, you may want to change the icons/images used by the
   119 ## NSIS installer, i.e. these variables:
   120 ##
   121 ## - CPACK_NSIS_MUI_ICON
   122 ## - CPACK_PACKAGE_ICON
   123 ## - CPACK_NSIS_INSTALLED_ICON_NAME
   124 ##
   125 ## and/or the files they point to.
   126 #######################################################################
   127 
   128 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
   129   SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
   130   SET(CPACK_PACKAGE_VENDOR "EGRES")
   131   SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
   132       "LEMON PROJECT TEMPLATE - A Template Build Environment for LEMON")
   133   SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
   134 
   135   SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
   136 
   137   SET(CPACK_PACKAGE_INSTALL_DIRECTORY
   138       "${PROJECT_NAME}")
   139   SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
   140       "${PROJECT_NAME}")
   141 
   142   SET(CPACK_COMPONENTS_ALL
   143       html_documentation
   144       bin)
   145 
   146   SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
   147   SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
   148 
   149   SET(CPACK_COMPONENT_BIN_DESCRIPTION
   150       "Command line utilities")
   151   SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
   152       "Doxygen generated documentation")
   153 
   154   SET(CPACK_GENERATOR "NSIS")
   155 
   156   SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon-project.ico")
   157   SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
   158   SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
   159   SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon-project.ico")
   160 
   161   SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
   162   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
   163   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
   164   SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
   165   SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
   166       CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
   167       ")
   168   SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
   169       !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
   170       Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
   171       ")
   172 
   173   INCLUDE(CPack)
   174 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})