Skip to content

Commit

Permalink
Merge with CMake branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Emmerson committed Sep 16, 2013
2 parents 7e9d39f + d114016 commit 2e40e85
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 23 deletions.
177 changes: 177 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
PROJECT (udunits C)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

SET(udunits_VERSION_MAJOR 2)
SET(udunits_VERSION_MINOR 1)
SET(udunits_VERSION_PATCH 26)
SET(DEFAULT_UDUNITS2_XML_PATH "${CMAKE_INSTALL_PREFIX}/share/udunits/udunits2.xml")

INCLUDE(CheckFunctionExists)
INCLUDE(CTest)
# The following fails on Gilda:
#INCLUDE(GNUInstallDirs)
# Hence:
SET(CMAKE_INSTALL_INFODIR share/info)
SET(CMAKE_INSTALL_FULL_INFODIR share/info)

# Creates an info(1)-file from texinfo(5) input
find_program(MAKEINFO makeinfo)
function(make_info output input)
add_custom_command(
OUTPUT ${output}
MAIN_DEPENDENCY ${input}
DEPENDS ${ARGN}
COMMAND ${MAKEINFO} -o ${output} -I ${CMAKE_SOURCE_DIR} ${input}
VERBATIM
COMMENT "Creating info(1) file ${output}")
endfunction(make_info)

# Installs an info(1)-file
find_program(INSTALL_INFO install-info)
IF (NOT INSTALL_INFO)
MESSAGE("install-info(1) not found. Top-level info(1)-file will not be adjusted.")
ELSE()
EXECUTE_PROCESS(COMMAND ${INSTALL_INFO} --version OUTPUT_QUIET
RESULT_VARIABLE status)
IF(NOT status EQUAL "0")
MESSAGE("install-info(1) failure. Top-level info(1)-file will not be adjusted.")
SET(INSTALL_INFO "NO")
ELSE()
EXECUTE_PROCESS(COMMAND ${INSTALL_INFO} --version COMMAND head -1
COMMAND grep -q -i -v debian RESULT_VARIABLE status)
IF(NOT status EQUAL "0")
MESSAGE("Debian system. Top-level info(1)-file will not be adjusted.")
SET(INSTALL_INFO "NO")
ENDIF()
ENDIF()
ENDIF()
FUNCTION(INSTALL_INFO input)
INSTALL(FILES ${input} DESTINATION ${CMAKE_INSTALL_INFODIR})
IF(INSTALL_INFO)
SET(relOutput "${CMAKE_INSTALL_INFODIR}/${input}")
add_custom_command(
OUTPUT "${CMAKE_INSTALL_INFODIR}/dir"
MAIN_DEPENDENCY "${relOutput}"
COMMAND ${INSTALL_INFO} --info-dir="${CMAKE_INSTALL_FULL_INFODIR}"
"${CMAKE_INSTALL_FULL_INFODIR}/${input}"
VERBATIM
COMMENT "Adjusting top-level info(1)-file according to ${relOutput}")
# add_custom_command(
# OUTPUT "${relOutput}"
# MAIN_DEPENDENCY "${input}"
# COMMAND ${INSTALL_INFO} --info-dir="${CMAKE_INSTALL_FULL_INFODIR}"
# "${CMAKE_INSTALL_FULL_INFODIR}/${input}"
# VERBATIM
# COMMENT "Adjusting top-level info(1)-file according to ${relOutput}")
# The following doesn't work because "adjust_top_info" isn't an executable,...
# add_custom_target(adjust_top_info
# COMMAND ${INSTALL_INFO} --info-dir="${CMAKE_INSTALL_FULL_INFODIR}"
# "${CMAKE_INSTALL_FULL_INFODIR}/${input}"
# VERBATIM
# DEPENDS "${CMAKE_INSTALL_FULL_INFODIR}/${input}")
# install(TARGETS adjust_top_info)
ENDIF()
ENDFUNCTION()

# This package uses math functions
CHECK_FUNCTION_EXISTS(log10 HAVE_LOG10)
IF (NOT HAVE_LOG10)
FIND_LIBRARY(LD_M NAMES math m)
IF(NOT LD_M)
MESSAGE(FATAL_ERROR "Unable to find the math library.")
ENDIF()
ENDIF()

# The EXPAT (SAX XML parser) library is used to parse the units database
FIND_LIBRARY(LD_EXPAT expat)
IF(NOT LD_EXPAT)
MESSAGE(FATAL_ERROR "Unable to find the EXPAT library.")
ENDIF()

# The CUnit library is used for unit-testing
FIND_LIBRARY(LD_CUNIT cunit)
IF(LD_CUNIT)
MESSAGE(STATUS "Found CUnit library: ${LD_CUNIT}")
ELSE()
MESSAGE("Unable to find the CUnit library. Unit-testing disabled.")
ENDIF()

CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/config.h.cmake"
"${PROJECT_BINARY_DIR}/config.h")
# Necessary for the compiler to find "config.h":
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")

ENABLE_TESTING()

ADD_SUBDIRECTORY (lib)
ADD_SUBDIRECTORY (prog)

INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Support for units of physical quantities")
SET(CPACK_PACKAGE_VENDOR "University Corporation for Atmospheric Research")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYRIGHT")
SET(CPACK_PACKAGE_VERSION_MAJOR ${udunits_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${udunits_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${udunits_VERSION_PATCH})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "udunits-${udunits_VERSION_MAJOR}.${udunits_VERSION_MINOR}")
#IF(WIN32 AND NOT UNIX)
# # There is a bug in NSI that does not handle full unix paths properly. Make
# # sure there is at least one set of four (4) backlasshes.
# SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
# SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
# SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} My Famous Project")
# SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org")
# SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")
# SET(CPACK_NSIS_CONTACT "me@my-personal-home-page.com")
# SET(CPACK_NSIS_MODIFY_PATH ON)
#ELSE(WIN32 AND NOT UNIX)
SET(CPACK_STRIP_FILES "bin/udunits2")
SET(CPACK_SOURCE_STRIP_FILES "")
#ENDIF(WIN32 AND NOT UNIX)
SET(CPACK_PACKAGE_EXECUTABLES "udunits2" "udunits2")
SET(CPACK_GENERATOR "Unix Makefiles")
INCLUDE(CPack)


# The documentation is in texinfo(5) format
find_program(MAKEINFO makeinfo)
make_info(udunits2.info ${CMAKE_CURRENT_SOURCE_DIR}/udunits2.texi
${CMAKE_CURRENT_SOURCE_DIR}/version.texi
${CMAKE_CURRENT_SOURCE_DIR}/COPYRIGHT)
add_custom_target(udunits2_info ALL DEPENDS udunits2.info)

# The documentation is in texinfo(5) format and must be composed
#set(results_tab ${CMAKE_CURRENT_SOURCE_DIR}/test/results.tab)
#add_custom_command(
# OUTPUT success.texi
# DEPENDS ${results_tab}
# COMMAND sort -u -t : -k 2,2 -k 4,4 -k 5,5 ${results_tab} |
# awk -F: '
# BEGIN {
# print \"@multitable {@code{Linux 2.6.18-1.2257.fc5smp}} {@code{/opt/csw/gcc4/bin/gcc}} {@code{--disable-shared}}\";
# print \"@headitem O/S @tab Compiler @tab @code{configure} Option\";
# }
# $$6 == 1 {
# printf \"@item @code{%s} @tab @code{%s} @tab @code{%s}\\n\",
# $$2, $$4, $$5;
# }
# END {
# print \"@end multitable\";
# }' >success.texi)
#find_program(MAKEINFO makeinfo)
#set(texinfo_in ${CMAKE_CURRENT_SOURCE_DIR}/udunits2.texi)
# ${CMAKE_CURRENT_BINARY_DIR}/success.texi
# ${CMAKE_CURRENT_BINARY_DIR}/failure.texi
# ${CMAKE_CURRENT_BINARY_DIR}/make.texi)
#set(texinfo_in ${CMAKE_CURRENT_SOURCE_DIR}/udunits2.texi)
#add_custom_command(
# OUTPUT udunits2.info
# DEPENDS ${texinfo_in}
# COMMAND ${MAKEINFO} -o udunits2.info ${texinfo_in}
# COMMENT "Creating Info file udunits2.info"
# VERBATIM)
#add_custom_target(texinfo ALL DEPENDS udunits2.info)
12 changes: 12 additions & 0 deletions config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
find_program(MAKEINFO makeinfo)

# Creates an info(1)-file from texinfo(5) input
function(make_info output input)
add_custom_command(
OUTPUT ${output}
MAIN_DEPENDENCY ${input}
DEPENDS ${ARGN}
COMMAND ${MAKEINFO} -o ${output} -I ${CMAKE_SOURCE_DIR} ${input}
VERBATIM
COMMENT "Creating info(1) file ${output}")
endfunction(make_info)
4 changes: 4 additions & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
* C macros set by cmake(1)
*/
#define DEFAULT_UDUNITS2_XML_PATH "@DEFAULT_UDUNITS2_XML_PATH@"
16 changes: 16 additions & 0 deletions prog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include_directories ("${PROJECT_SOURCE_DIR}/lib")

link_directories (${PROJECT_BINARY_DIR}/lib)

add_executable(udunits2 udunits2.c)

target_link_libraries (udunits2 libudunits2)
target_link_libraries (udunits2 ${LD_EXPAT})
target_link_libraries (udunits2 ${LD_M})

# The documentation is in multiple texinfo(5) format files
make_info(udunits2prog.info ${CMAKE_CURRENT_SOURCE_DIR}/udunits2prog.texi
${CMAKE_SOURCE_DIR}/COPYRIGHT)
add_custom_target(udunits2prog ALL DEPENDS udunits2prog.info)

install(TARGETS udunits2 DESTINATION bin)
23 changes: 0 additions & 23 deletions udunits2.texi
Original file line number Diff line number Diff line change
Expand Up @@ -167,41 +167,18 @@ Go to the top-level source-directory of this package, e.g.,
cd udunits-@value{VERSION}
@end example

@item
Because some @code{make} utilities cannot build this package correctly,
locate the operating system that is closest to yours in the following table
and determine the @var{make} utility that you will use.
@quotation
@include make.texi
@end quotation

@item
If necessary, clean-up from a previous installation attempt by making
the @code{distclean} target using the @var{make} utility from step 2:
@example
@var{make} distclean
@end example

@item
Because some compilers cannot build this package correctly,
locate the operating system closest to yours in the following table
and determine the compiler
that you will use and any required option for the @code{configure} script.
@quotation
@include success.texi
@end quotation

The option @code{--disable-shared} causes the build process to create
a static library only: a sharable library is not created.
This option is necessary if the @code{libtool} utility that's included
in this package can't build a sharable library using the given compiler.

The following table lists the build environments that do not work ---
so don't use them:
@quotation
@include failure.texi
@end quotation

@item
Execute the @code{configure} script.
Specify the installation prefix, the compiler from the
Expand Down

0 comments on commit 2e40e85

Please sign in to comment.