author | Alpar Juttner <alpar@cs.elte.hu> |
Sun, 05 Dec 2010 17:35:23 +0100 | |
changeset 2 | 4c8956a7bdf4 |
permissions | -rw-r--r-- |
alpar@2 | 1 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
alpar@2 | 2 |
|
alpar@2 | 3 |
SET(PROJECT_NAME "GLPK") |
alpar@2 | 4 |
PROJECT(${PROJECT_NAME}) |
alpar@2 | 5 |
|
alpar@2 | 6 |
IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake) |
alpar@2 | 7 |
INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake) |
alpar@2 | 8 |
ELSEIF(DEFINED ENV{GLPK_VERSION}) |
alpar@2 | 9 |
SET(GLPK_VERSION $ENV{GLPK_VERSION} CACHE STRING "GLPK version string.") |
alpar@2 | 10 |
ELSE() |
alpar@2 | 11 |
EXECUTE_PROCESS( |
alpar@2 | 12 |
COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py |
alpar@2 | 13 |
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
alpar@2 | 14 |
OUTPUT_VARIABLE HG_REVISION_PATH |
alpar@2 | 15 |
ERROR_QUIET |
alpar@2 | 16 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
alpar@2 | 17 |
) |
alpar@2 | 18 |
EXECUTE_PROCESS( |
alpar@2 | 19 |
COMMAND hg id -i |
alpar@2 | 20 |
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
alpar@2 | 21 |
OUTPUT_VARIABLE HG_REVISION |
alpar@2 | 22 |
ERROR_QUIET |
alpar@2 | 23 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
alpar@2 | 24 |
) |
alpar@2 | 25 |
IF(HG_REVISION STREQUAL "") |
alpar@2 | 26 |
SET(HG_REVISION_ID "hg-tip") |
alpar@2 | 27 |
ELSE() |
alpar@2 | 28 |
IF(HG_REVISION_PATH STREQUAL "") |
alpar@2 | 29 |
SET(HG_REVISION_ID ${HG_REVISION}) |
alpar@2 | 30 |
ELSE() |
alpar@2 | 31 |
SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION}) |
alpar@2 | 32 |
ENDIF() |
alpar@2 | 33 |
ENDIF() |
alpar@2 | 34 |
SET(GLPK_VERSION ${HG_REVISION_ID} CACHE STRING "GLPK version string.") |
alpar@2 | 35 |
ENDIF() |
alpar@2 | 36 |
|
alpar@2 | 37 |
SET(PROJECT_VERSION ${GLPK_VERSION}) |
alpar@2 | 38 |
|
alpar@2 | 39 |
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
alpar@2 | 40 |
|
alpar@2 | 41 |
IF(DEFINED ENV{GLPK_C_WARNING}) |
alpar@2 | 42 |
SET(C_WARNING $ENV{GLPK_C_WARNING}) |
alpar@2 | 43 |
ELSE() |
alpar@2 | 44 |
IF(CMAKE_COMPILER_IS_GNUC) |
alpar@2 | 45 |
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") |
alpar@2 | 46 |
SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb") |
alpar@2 | 47 |
SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb") |
alpar@2 | 48 |
ELSEIF(MSVC) |
alpar@2 | 49 |
# SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996") |
alpar@2 | 50 |
# # suppressed warnings: |
alpar@2 | 51 |
# # C4250: 'class1' : inherits 'class2::member' via dominance |
alpar@2 | 52 |
# # C4355: 'this' : used in base member initializer list |
alpar@2 | 53 |
# # C4503: 'function' : decorated name length exceeded, name was truncated |
alpar@2 | 54 |
# # C4800: 'type' : forcing value to bool 'true' or 'false' |
alpar@2 | 55 |
# # (performance warning) |
alpar@2 | 56 |
# # C4996: 'function': was declared deprecated |
alpar@2 | 57 |
ELSE() |
alpar@2 | 58 |
SET(C_WARNING "-Wall -W") |
alpar@2 | 59 |
ENDIF() |
alpar@2 | 60 |
ENDIF() |
alpar@2 | 61 |
SET(GLPK_C_WARNING_FLAGS ${C_WARNING} CACHE STRING "GLPK warning flags.") |
alpar@2 | 62 |
|
alpar@2 | 63 |
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLPK_C_WARNING_FLAGS}") |
alpar@2 | 64 |
|
alpar@2 | 65 |
SET(CMAKE_C_FLAGS_MAINTAINER "-ggdb" CACHE STRING |
alpar@2 | 66 |
"Flags used by the C compiler during maintainer builds." |
alpar@2 | 67 |
FORCE ) |
alpar@2 | 68 |
SET(CMAKE_EXE_LINKER_FLAGS_MAINTAINER |
alpar@2 | 69 |
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING |
alpar@2 | 70 |
"Flags used for linking binaries during maintainer builds." |
alpar@2 | 71 |
FORCE ) |
alpar@2 | 72 |
SET(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER |
alpar@2 | 73 |
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING |
alpar@2 | 74 |
"Flags used by the shared libraries linker during maintainer builds." |
alpar@2 | 75 |
FORCE ) |
alpar@2 | 76 |
MARK_AS_ADVANCED( |
alpar@2 | 77 |
CMAKE_C_FLAGS_MAINTAINER |
alpar@2 | 78 |
CMAKE_EXE_LINKER_FLAGS_MAINTAINER |
alpar@2 | 79 |
CMAKE_SHARED_LINKER_FLAGS_MAINTAINER ) |
alpar@2 | 80 |
|
alpar@2 | 81 |
IF(CMAKE_CONFIGURATION_TYPES) |
alpar@2 | 82 |
LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer) |
alpar@2 | 83 |
LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES) |
alpar@2 | 84 |
SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING |
alpar@2 | 85 |
"Add the configurations that we need" |
alpar@2 | 86 |
FORCE) |
alpar@2 | 87 |
endif() |
alpar@2 | 88 |
|
alpar@2 | 89 |
IF(NOT CMAKE_BUILD_TYPE) |
alpar@2 | 90 |
SET(CMAKE_BUILD_TYPE "Release") |
alpar@2 | 91 |
ENDIF() |
alpar@2 | 92 |
|
alpar@2 | 93 |
SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING |
alpar@2 | 94 |
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer." |
alpar@2 | 95 |
FORCE ) |
alpar@2 | 96 |
|
alpar@2 | 97 |
|
alpar@2 | 98 |
INCLUDE(CheckTypeSize) |
alpar@2 | 99 |
CHECK_TYPE_SIZE("long long" LONG_LONG) |
alpar@2 | 100 |
SET(GLPK_HAVE_LONG_LONG ${HAVE_LONG_LONG}) |
alpar@2 | 101 |
|
alpar@2 | 102 |
ENABLE_TESTING() |
alpar@2 | 103 |
|
alpar@2 | 104 |
IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") |
alpar@2 | 105 |
ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND}) |
alpar@2 | 106 |
ELSE() |
alpar@2 | 107 |
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) |
alpar@2 | 108 |
ENDIF() |
alpar@2 | 109 |
|
alpar@2 | 110 |
INCLUDE_DIRECTORIES( |
alpar@2 | 111 |
${PROJECT_SOURCE_DIR}/include |
alpar@2 | 112 |
${PROJECT_SOURCE_DIR}/src |
alpar@2 | 113 |
) |
alpar@2 | 114 |
|
alpar@2 | 115 |
INCLUDE(FindLATEX) |
alpar@2 | 116 |
|
alpar@2 | 117 |
ADD_SUBDIRECTORY(src) |
alpar@2 | 118 |
ADD_SUBDIRECTORY(include) |
alpar@2 | 119 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
alpar@2 | 120 |
ADD_SUBDIRECTORY(examples) |
alpar@2 | 121 |
ADD_SUBDIRECTORY(doc) |
alpar@2 | 122 |
ENDIF() |
alpar@2 | 123 |
|
alpar@2 | 124 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
alpar@2 | 125 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) |
alpar@2 | 126 |
SET(CPACK_PACKAGE_VENDOR "GNU") |
alpar@2 | 127 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
alpar@2 | 128 |
"GLPK - GNU Linear Programming Kit") |
alpar@2 | 129 |
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") |
alpar@2 | 130 |
|
alpar@2 | 131 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) |
alpar@2 | 132 |
|
alpar@2 | 133 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
alpar@2 | 134 |
"${PROJECT_NAME} ${PROJECT_VERSION}") |
alpar@2 | 135 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
alpar@2 | 136 |
"${PROJECT_NAME} ${PROJECT_VERSION}") |
alpar@2 | 137 |
|
alpar@2 | 138 |
INCLUDE(CPack) |
alpar@2 | 139 |
|
alpar@2 | 140 |
CPACK_ADD_INSTALL_TYPE(Full) |
alpar@2 | 141 |
|
alpar@2 | 142 |
CPACK_ADD_COMPONENT(headers |
alpar@2 | 143 |
DISPLAY_NAME "C headers" |
alpar@2 | 144 |
DESCRIPTION "C header files" |
alpar@2 | 145 |
DEPENDS library |
alpar@2 | 146 |
INSTALL_TYPES Full |
alpar@2 | 147 |
) |
alpar@2 | 148 |
CPACK_ADD_COMPONENT(library |
alpar@2 | 149 |
DISPLAY_NAME "Libraries" |
alpar@2 | 150 |
DESCRIPTION "DLL and import library" |
alpar@2 | 151 |
INSTALL_TYPES Full |
alpar@2 | 152 |
) |
alpar@2 | 153 |
|
alpar@2 | 154 |
CPACK_ADD_COMPONENT(bin |
alpar@2 | 155 |
DISPLAY_NAME "Command line utilities" |
alpar@2 | 156 |
DESCRIPTION "Command line utilities" |
alpar@2 | 157 |
INSTALL_TYPES Full |
alpar@2 | 158 |
) |
alpar@2 | 159 |
|
alpar@2 | 160 |
SET(CPACK_GENERATOR "NSIS") |
alpar@2 | 161 |
# SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/glpk.ico") |
alpar@2 | 162 |
# SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico") |
alpar@2 | 163 |
# #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp") |
alpar@2 | 164 |
# SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\glpk.ico") |
alpar@2 | 165 |
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") |
alpar@2 | 166 |
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.gnu.org\\\\software\\\\glpk") |
alpar@2 | 167 |
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.gnu.org\\\\software\\\\glpk") |
alpar@2 | 168 |
SET(CPACK_NSIS_CONTACT "mao@gnu.org") |
alpar@2 | 169 |
# SET(CPACK_NSIS_CREATE_ICONS_EXTRA " |
alpar@2 | 170 |
# CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\" |
alpar@2 | 171 |
# ") |
alpar@2 | 172 |
# SET(CPACK_NSIS_DELETE_ICONS_EXTRA " |
alpar@2 | 173 |
# !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
alpar@2 | 174 |
# Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" |
alpar@2 | 175 |
# ") |
alpar@2 | 176 |
|
alpar@2 | 177 |
ENDIF() |