CMakeLists.txt
changeset 2 4c8956a7bdf4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/CMakeLists.txt	Sun Dec 05 17:35:23 2010 +0100
     1.3 @@ -0,0 +1,177 @@
     1.4 +CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     1.5 +
     1.6 +SET(PROJECT_NAME "GLPK")
     1.7 +PROJECT(${PROJECT_NAME})
     1.8 +
     1.9 +IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    1.10 +  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    1.11 +ELSEIF(DEFINED ENV{GLPK_VERSION})
    1.12 +  SET(GLPK_VERSION $ENV{GLPK_VERSION} CACHE STRING "GLPK version string.")
    1.13 +ELSE()
    1.14 +  EXECUTE_PROCESS(
    1.15 +    COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
    1.16 +    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    1.17 +    OUTPUT_VARIABLE HG_REVISION_PATH
    1.18 +    ERROR_QUIET
    1.19 +    OUTPUT_STRIP_TRAILING_WHITESPACE
    1.20 +  )
    1.21 +  EXECUTE_PROCESS(
    1.22 +    COMMAND hg id -i
    1.23 +    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    1.24 +    OUTPUT_VARIABLE HG_REVISION
    1.25 +    ERROR_QUIET
    1.26 +    OUTPUT_STRIP_TRAILING_WHITESPACE
    1.27 +  )
    1.28 +  IF(HG_REVISION STREQUAL "")
    1.29 +    SET(HG_REVISION_ID "hg-tip")
    1.30 +  ELSE()
    1.31 +    IF(HG_REVISION_PATH STREQUAL "")
    1.32 +      SET(HG_REVISION_ID ${HG_REVISION})
    1.33 +    ELSE()
    1.34 +      SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
    1.35 +    ENDIF()
    1.36 +  ENDIF()
    1.37 +  SET(GLPK_VERSION ${HG_REVISION_ID} CACHE STRING "GLPK version string.")
    1.38 +ENDIF()
    1.39 +
    1.40 +SET(PROJECT_VERSION ${GLPK_VERSION})
    1.41 +
    1.42 +SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    1.43 +
    1.44 +IF(DEFINED ENV{GLPK_C_WARNING})
    1.45 +  SET(C_WARNING $ENV{GLPK_C_WARNING})
    1.46 +ELSE()
    1.47 +  IF(CMAKE_COMPILER_IS_GNUC)
    1.48 +    SET(C_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
    1.49 +    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
    1.50 +    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
    1.51 +  ELSEIF(MSVC)
    1.52 +    # SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
    1.53 +    # # suppressed warnings:
    1.54 +    # # C4250: 'class1' : inherits 'class2::member' via dominance
    1.55 +    # # C4355: 'this' : used in base member initializer list
    1.56 +    # # C4503: 'function' : decorated name length exceeded, name was truncated
    1.57 +    # # C4800: 'type' : forcing value to bool 'true' or 'false'
    1.58 +    # #        (performance warning)
    1.59 +    # # C4996: 'function': was declared deprecated
    1.60 +  ELSE()
    1.61 +    SET(C_WARNING "-Wall -W")
    1.62 +  ENDIF()
    1.63 +ENDIF()
    1.64 +SET(GLPK_C_WARNING_FLAGS ${C_WARNING} CACHE STRING "GLPK warning flags.")
    1.65 +
    1.66 +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLPK_C_WARNING_FLAGS}")
    1.67 +
    1.68 +SET(CMAKE_C_FLAGS_MAINTAINER "-ggdb" CACHE STRING
    1.69 +    "Flags used by the C compiler during maintainer builds."
    1.70 +    FORCE )
    1.71 +SET(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    1.72 +    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
    1.73 +    "Flags used for linking binaries during maintainer builds."
    1.74 +    FORCE )
    1.75 +SET(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
    1.76 +    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
    1.77 +    "Flags used by the shared libraries linker during maintainer builds."
    1.78 +    FORCE )
    1.79 +MARK_AS_ADVANCED(
    1.80 +    CMAKE_C_FLAGS_MAINTAINER
    1.81 +    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    1.82 +    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
    1.83 +
    1.84 +IF(CMAKE_CONFIGURATION_TYPES)
    1.85 +  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
    1.86 +  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
    1.87 +  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    1.88 +      "Add the configurations that we need"
    1.89 +      FORCE)
    1.90 + endif()
    1.91 +
    1.92 +IF(NOT CMAKE_BUILD_TYPE)
    1.93 +  SET(CMAKE_BUILD_TYPE "Release")
    1.94 +ENDIF()
    1.95 +
    1.96 +SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
    1.97 +  "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
    1.98 +  FORCE )
    1.99 +
   1.100 +
   1.101 +INCLUDE(CheckTypeSize)
   1.102 +CHECK_TYPE_SIZE("long long" LONG_LONG)
   1.103 +SET(GLPK_HAVE_LONG_LONG ${HAVE_LONG_LONG})
   1.104 +
   1.105 +ENABLE_TESTING()
   1.106 +
   1.107 +IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
   1.108 +  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
   1.109 +ELSE()
   1.110 +  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
   1.111 +ENDIF()
   1.112 +
   1.113 +INCLUDE_DIRECTORIES( 
   1.114 +  ${PROJECT_SOURCE_DIR}/include
   1.115 +  ${PROJECT_SOURCE_DIR}/src
   1.116 +)
   1.117 +
   1.118 +INCLUDE(FindLATEX)
   1.119 +
   1.120 +ADD_SUBDIRECTORY(src)
   1.121 +ADD_SUBDIRECTORY(include)
   1.122 +IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
   1.123 +  ADD_SUBDIRECTORY(examples)
   1.124 +  ADD_SUBDIRECTORY(doc)
   1.125 +ENDIF()
   1.126 +
   1.127 +IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
   1.128 +  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
   1.129 +  SET(CPACK_PACKAGE_VENDOR "GNU")
   1.130 +  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
   1.131 +    "GLPK - GNU Linear Programming Kit")
   1.132 +  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
   1.133 +
   1.134 +  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
   1.135 +
   1.136 +  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
   1.137 +    "${PROJECT_NAME} ${PROJECT_VERSION}")
   1.138 +  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
   1.139 +    "${PROJECT_NAME} ${PROJECT_VERSION}")
   1.140 +
   1.141 +  INCLUDE(CPack)
   1.142 +
   1.143 +  CPACK_ADD_INSTALL_TYPE(Full)   
   1.144 +  
   1.145 +  CPACK_ADD_COMPONENT(headers
   1.146 +    DISPLAY_NAME "C headers"
   1.147 +    DESCRIPTION "C header files"
   1.148 +    DEPENDS library
   1.149 +    INSTALL_TYPES Full
   1.150 +    )
   1.151 +  CPACK_ADD_COMPONENT(library
   1.152 +    DISPLAY_NAME "Libraries"
   1.153 +    DESCRIPTION "DLL and import library"
   1.154 +    INSTALL_TYPES Full
   1.155 +    )
   1.156 +
   1.157 +  CPACK_ADD_COMPONENT(bin
   1.158 +    DISPLAY_NAME "Command line utilities"
   1.159 +    DESCRIPTION "Command line utilities"
   1.160 +    INSTALL_TYPES Full
   1.161 +    )
   1.162 +
   1.163 +  SET(CPACK_GENERATOR "NSIS")
   1.164 +  # SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/glpk.ico")
   1.165 +  # SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
   1.166 +  # #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
   1.167 +  # SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\glpk.ico")
   1.168 +  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
   1.169 +  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.gnu.org\\\\software\\\\glpk")
   1.170 +  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.gnu.org\\\\software\\\\glpk")
   1.171 +  SET(CPACK_NSIS_CONTACT "mao@gnu.org")
   1.172 +  # SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
   1.173 +  #   CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
   1.174 +  #   ")
   1.175 +  # SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
   1.176 +  #   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
   1.177 +  #   Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
   1.178 +  #   ")
   1.179 +
   1.180 +ENDIF()