[Comm] CMake
Vladimir Karpinsky
vkarpinsky на mail.ru
Вс Мар 30 11:43:59 MSK 2014
Здравствуйте!
Помогите, пожалуйста, разобраться со сборкой пакета с помощью CMake.
Существует пакет GMT (http://gmt.soest.hawaii.edu), предназначенный для
работы с картографическими данными, нанесением на карты всяких графиков и
т.п. (GMT is an open source collection of about 80 command-line tools for
manipulating geographic and Cartesian data sets (including filtering, trend
fitting, gridding, projecting, etc.) and producing PostScript
illustrations...). Установка этого пакета всегда была витьеватой, а в
последнее время они ещё перешли на cmake, и у меня совсем перестало
получаться. В инструкции велено сделать следующее:
1. $ svn co svn://gmtserver.soest.hawaii.edu/gmt5/trunk gmt5-dev
2. $ cd gmt5-dev
3. $ cp cmake/ConfigUserTemplate.cmake cmake/ConfigUser.cmake
4. Edit *cmake/ConfigUser.cmake* [see comments in the file]. Then:
5. $ mkdir build
6. $ cd build
7. $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local
-DCMAKE_BUILD_TYPE=RelWithDebInfo ..
8. $ make -jx
До 6-го пункта включительно всё прошло штатно, а в п.7. получил ошибку:
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- broken
CMake Error at /usr/share/CMake/Modules/CMakeTestCXXCompiler.cmake:54
(message):
The C++ compiler "/usr/bin/c++" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /home/karp/gmt/gmt-5.1.1/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec2941133113/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec2941133113.dir/build.make
CMakeFiles/cmTryCompileExec2941133113.dir/build
gmake[1]: Вход в каталог
`/home/karp/gmt/gmt-5.1.1/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/karp/gmt/gmt-5.1.1/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec2941133113.dir/testCXXCompiler.cxx.o
/usr/bin/c++ -o
CMakeFiles/cmTryCompileExec2941133113.dir/testCXXCompiler.cxx.o -c
/home/karp/gmt/gmt-5.1.1/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
/usr/bin/x86_64-alt-linux-g++: No such file or directory
gmake[1]: ***
[CMakeFiles/cmTryCompileExec2941133113.dir/testCXXCompiler.cxx.o]
Ошибка 1
gmake[1]: Выход из каталога
`/home/karp/gmt/gmt-5.1.1/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec2941133113/fast] Ошибка 2
Углядев, что не находится /usr/bin/x86_64-alt-linux-g++, я подумал, что
cmake хочет видеть g++ с таким именем и сделал симлинк:
/usr/bin/x86_64-alt-linux-g++ -> /usr/bin/g++
Но последующий запуск выдаёт уже:
/usr/bin/x86_64-alt-linux-x86_64-alt-linux-g++: No such file or directory
??!
Насколько я понимаю, руководство к действию для cmake находится в файле
CMakeLists.txt, который прилагаю к этому письму.
--
С уважением,
Владимир.
----------- следующая часть -----------
#
# $Id: CMakeLists.txt 12910 2014-02-17 21:27:37Z fwobbe $
#
# Copyright (c) 1991-2014 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
# See LICENSE.TXT file for copying and redistribution conditions.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3 or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# Contact info: gmt.soest.hawaii.edu
#-------------------------------------------------------------------------------
#
# To modify the cmake process: Edit your cmake/ConfigUser.cmake file
#
# To build out-of-source do (example):
#
# mkdir build
# cd build
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
#
# CMAKE_BUILD_TYPE can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel
#
# cmake creates a new file cmake/ConfigUser.cmake if it does not already
# exist. You can configure additional options there.
#
# Make sure the user doesn't play dirty with symlinks
get_filename_component (srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component (bindir "${CMAKE_BINARY_DIR}" REALPATH)
# Disallow in-source builds
if (${srcdir} STREQUAL ${bindir})
message(FATAL_ERROR "In-source builds are not allowed. "
"Please create a directory and run cmake from there, passing the path "
"to this source directory as the last argument. This process created "
"the file `CMakeCache.txt' and the directory `CMakeFiles' in ${srcdir}. "
"Please remove them.")
endif (${srcdir} STREQUAL ${bindir})
# Define minimum CMake version required
cmake_minimum_required (VERSION 2.8.5)
# Define project name
project (GMT)
# Where to find our CMake modules (this variable is visible in subdirectories).
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/"
CACHE INTERNAL "Location of our custom CMake modules." FORCE)
# Include configuration options (default options and options overridden by user).
include (ConfigCMake)
# Find UNIX commands
include (FindUnixCommands)
find_program (SVN svn)
# Global test target
add_custom_target (check
COMMAND ${CMAKE_CTEST_COMMAND}
--force-new-ctest-process -j${N_TEST_JOBS})
# Find test dependencies
find_program (GRAPHICSMAGICK gm)
if (DO_EXAMPLES OR DO_TESTS AND NOT GRAPHICSMAGICK)
message (FATAL_ERROR "Cannot proceed without GraphicsMagick. "
"Need to either install GraphicsMagick or disable tests.")
endif (DO_EXAMPLES OR DO_TESTS AND NOT GRAPHICSMAGICK)
# Add subdirectories
#set(_manfiles_ps "" CACHE INTERNAL "Global list of PS manpages")
add_subdirectory (src)
add_subdirectory (share) # share must be processed *after* src (GSHHG_PATH)
add_subdirectory (doc) # share must be processed *after* src (PDF manpages)
add_subdirectory (test)
add_subdirectory (cmake/dist) # make distribution bundles (always last)
# Source release target
if (SVN AND HAVE_SVN_VERSION)
# Export svn working tree
add_custom_target (svn_export_release
COMMAND ${SVN} --force export
${GMT_SOURCE_DIR} ${GMT_RELEASE_PREFIX})
add_depend_to_target (gmt_release svn_export_release)
find_program (GNUTAR NAMES gnutar gtar tar)
if (GNUTAR)
# Targets for creating tarballs
string (REGEX REPLACE ".*/" "" _release_dirname "${GMT_RELEASE_PREFIX}")
add_custom_command (OUTPUT ${_release_dirname}-src.tar.gz
COMMAND ${GNUTAR} -cz --owner 0 --group 0 --mode a=rX,u=rwX
-f ${GMT_BINARY_DIR}/${_release_dirname}-src.tar.gz ${_release_dirname}
DEPENDS ${GMT_RELEASE_PREFIX}
WORKING_DIRECTORY ${GMT_RELEASE_PREFIX}/..
VERBATIM)
add_custom_command (OUTPUT ${_release_dirname}-src.tar.bz2
COMMAND ${GNUTAR} -cj --owner 0 --group 0 --mode a=rX,u=rwX
-f ${GMT_BINARY_DIR}/${_release_dirname}-src.tar.bz2 ${_release_dirname}
DEPENDS ${GMT_RELEASE_PREFIX}
WORKING_DIRECTORY ${GMT_RELEASE_PREFIX}/..
VERBATIM)
add_custom_target (gmt_release_tar
DEPENDS ${GMT_RELEASE_PREFIX}
${_release_dirname}-src.tar.gz ${_release_dirname}-src.tar.bz2)
endif (GNUTAR)
endif (SVN AND HAVE_SVN_VERSION)
get_target_property (_location gmtlib LOCATION)
get_filename_component (GMT_CORE_LIB_NAME ${_location} NAME)
get_target_property (_location pslib LOCATION)
get_filename_component (PSL_LIB_NAME ${_location} NAME)
if (BUILD_SUPPLEMENTS)
# Get name of shared supplemental library
get_target_property (_location supplib LOCATION)
get_filename_component (GMT_SUPPL_LIB_NAME ${_location} NAME)
set (SUPPL "yes [${GMT_SUPPL_LIB_NAME}]")
else (BUILD_SUPPLEMENTS)
set (SUPPL "no")
endif (BUILD_SUPPLEMENTS)
if (BUILD_SHARED_LIBS)
set (BUILD_MODE "shared")
else (BUILD_SHARED_LIBS)
set (BUILD_MODE "static")
endif (BUILD_SHARED_LIBS)
if (EXTRA_BUILD_DIRS)
set (PROTO ${EXTRA_BUILD_DIRS})
else (EXTRA_BUILD_DIRS)
set (PROTO "none")
endif (EXTRA_BUILD_DIRS)
# Configure a header file to pass some of the CMake settings to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h")
# Configuration done
message(
"* Options:\n"
"* Found GSHHG database : ${GSHHG_PATH} (${GSHHG_VERSION})\n"
"* Found DCW-GMT database : ${DCW_PATH}\n"
"* NetCDF library : ${NETCDF_LIBRARY}\n"
"* NetCDF include dir : ${NETCDF_INCLUDE_DIR}\n"
"* GDAL library : ${GDAL_LIBRARY}\n"
"* GDAL include dir : ${GDAL_INCLUDE_DIR}\n"
"* FFTW library : ${FFTW3F_LIBRARY}\n"
"* FFTW include dir : ${FFTW3_INCLUDE_DIR}\n"
"* Accelerate Framework : ${ACCELERATE_FRAMEWORK}\n"
"* Regex support : ${GMT_CONFIG_REGEX_MESSAGE}\n"
"* ZLIB library : ${ZLIB_LIBRARY}\n"
"* ZLIB include dir : ${ZLIB_INCLUDE_DIR}\n"
"* License restriction : ${LICENSE_RESTRICTED}\n"
"* Triangulation method : ${GMT_TRIANGULATE}\n"
"* Build mode : ${BUILD_MODE}\n"
"* Build GMT core : always [${GMT_CORE_LIB_NAME}]\n"
"* Build PSL library : always [${PSL_LIB_NAME}]\n"
"* Build GMT supplements : ${SUPPL}\n"
"* Build proto supplements : ${PROTO}\n"
"*\n"
"* Locations:\n"
"* Installing GMT in : ${CMAKE_INSTALL_PREFIX}\n"
"* GMT_DATADIR : ${CMAKE_INSTALL_PREFIX}/${GMT_DATADIR}\n"
"* GMT_DOCDIR : ${CMAKE_INSTALL_PREFIX}/${GMT_DOCDIR}\n"
"* GMT_MANDIR : ${CMAKE_INSTALL_PREFIX}/${GMT_MANDIR}")
# For debugging: print all set variables
#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Подробная информация о списке рассылки community