Add option to use a system-installed KWIML

Do not activate it with the general use-system-libs options for now
because KWIML is not commonly distributed or available.
This commit is contained in:
Brad King 2015-12-18 09:57:55 -05:00
parent 036b6ef7c4
commit a5dd0c9d42
6 changed files with 48 additions and 5 deletions

View File

@ -138,8 +138,13 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_FORM}")
option(CMAKE_USE_SYSTEM_JSONCPP "Use system-installed jsoncpp" "${CMAKE_USE_SYSTEM_LIBRARY_JSONCPP}")
# For now use system KWIML only if explicitly requested rather
# than activating via the general system libs options.
option(CMAKE_USE_SYSTEM_KWIML "Use system-installed KWIML" OFF)
mark_as_advanced(CMAKE_USE_SYSTEM_KWIML)
# Mention to the user what system libraries are being used.
foreach(util ${UTILITIES})
foreach(util ${UTILITIES} KWIML)
if(CMAKE_USE_SYSTEM_${util})
message(STATUS "Using system-installed ${util}")
endif()
@ -270,6 +275,20 @@ macro (CMAKE_BUILD_UTILITIES)
# (a macro defined in this file)
CMAKE_HANDLE_SYSTEM_LIBRARIES()
if(CMAKE_USE_SYSTEM_KWIML)
find_package(KWIML 1.0)
if(NOT KWIML_FOUND)
message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!")
endif()
set(CMake_KWIML_LIBRARIES kwiml::kwiml)
else()
set(CMake_KWIML_LIBRARIES "")
if(BUILD_TESTING)
set(KWIML_TEST_ENABLE 1)
endif()
add_subdirectory(Utilities/KWIML)
endif()
#---------------------------------------------------------------------
# Build zlib library for Curl, CMake, and CTest.
set(CMAKE_ZLIB_HEADER "cm_zlib.h")
@ -538,10 +557,10 @@ if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
set(CMAKE_TESTS_CDASH_SERVER "http://open.cdash.org")
endif()
if(BUILD_TESTING)
if(CMake_TEST_EXTERNAL_CMAKE)
set(KWIML_TEST_ENABLE 1)
endif()
add_subdirectory(Utilities/KWIML)
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# build the utilities (a macro defined in this file)

View File

@ -566,6 +566,7 @@ target_link_libraries(CMakeLib cmsys
${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
${CMAKE_CURL_LIBRARIES}
${CMAKE_JSONCPP_LIBRARIES}
${CMake_KWIML_LIBRARIES}
)
# On Apple we need CoreFoundation

View File

@ -15,6 +15,7 @@
/* Whether CMake is using its own utility libraries. */
#cmakedefine CMAKE_USE_SYSTEM_CURL
#cmakedefine CMAKE_USE_SYSTEM_EXPAT
#cmakedefine CMAKE_USE_SYSTEM_KWIML
#cmakedefine CMAKE_USE_SYSTEM_ZLIB
#cmakedefine CMAKE_USE_SYSTEM_BZIP2
#cmakedefine CMAKE_USE_SYSTEM_LIBARCHIVE

View File

@ -12,7 +12,14 @@
#ifndef cm_kwiml_h
#define cm_kwiml_h
/* Use the KWIML library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_KWIML
# include <kwiml/abi.h>
# include <kwiml/int.h>
#else
# include "KWIML/include/kwiml/abi.h"
# include "KWIML/include/kwiml/int.h"
#endif
#endif

View File

@ -23,3 +23,4 @@ include_directories(
)
add_library(cmjsoncpp ${JSONCPP_SOURCES})
target_link_libraries(cmjsoncpp ${CMake_KWIML_LIBRARIES})

View File

@ -450,6 +450,18 @@ cmake_error()
exit ${res}
}
cmake_generate_file ()
{
OUTFILE="$1"
CONTENT="$2"
echo "$CONTENT" > "$OUTFILE.tmp"
if "${_diff}" "$OUTFILE.tmp" "$OUTFILE" > /dev/null 2> /dev/null ; then
rm -f "$OUTFILE.tmp"
else
mv -f "$OUTFILE.tmp" "$OUTFILE"
fi
}
# Replace KWSYS_NAMESPACE with cmsys
cmake_replace_string ()
{
@ -1270,6 +1282,8 @@ for a in ${KWSYS_FILES}; do
"${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
done
cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" ""
# Generate Makefile
dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
objs=""