aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2020-02-25 20:42:31 +0200
committerLasse Collin <lasse.collin@tukaani.org>2020-02-25 20:44:10 +0200
commit474320e9908786ba2021035f9013191e16cde08a (patch)
treebd221ac4a0d61f8b5db1e0681ae5268d1dbbedd4 /CMakeLists.txt
parentBuild: Add very limited experimental CMake support. (diff)
downloadxz-474320e9908786ba2021035f9013191e16cde08a.tar.xz
Build: Fix bugs in the CMake files.
Seems that the phrase "add more quotes" from sh/bash scripting applies to CMake as well. E.g. passing an unquoted list ${FOO} to a function that expects one argument results in only the first element of the list being passed as an argument and the rest get ignored. Adding quotes helps ("${FOO}"). list(INSERT ...) is weird. Inserting an empty string to an empty variable results in empty list, but inserting it to a non-empty variable does insert an empty element to the list. Since INSERT requires at least one element, "${CMAKE_THREAD_LIBS_INIT}" needs to be quoted in CMakeLists.txt. It might result in an empty element in the list. It seems to not matter as empty elements consistently get ignored in that variable. In fact, calling cmake_check_push_state() and cmake_check_pop_state() will strip the empty elements from CMAKE_REQUIRED_LIBRARIES! In addition to quoting fixes, this fixes checks for the cache variables in tuklib_cpucores.cmake and tuklib_physmem.cmake. Thanks to Martin Matuška for testing and reporting the problems. These fixes aren't tested yet but hopefully they soon will be.
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt52
1 files changed, 26 insertions, 26 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5b840b46..7767896e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,10 +65,10 @@ string(REGEX REPLACE
#define LZMA_VERSION_MINOR ([0-9]+)\n\
#define LZMA_VERSION_PATCH ([0-9]+)\n\
.*$"
- "\\1.\\2.\\3" XZ_VERSION ${XZ_VERSION})
+ "\\1.\\2.\\3" XZ_VERSION "${XZ_VERSION}")
# Among other things, this gives us variables xz_VERSION and xz_VERSION_MAJOR.
-project(xz VERSION ${XZ_VERSION} LANGUAGES C)
+project(xz VERSION "${XZ_VERSION}" LANGUAGES C)
# Definitions common to all targets:
add_compile_definitions(
@@ -152,7 +152,7 @@ if(NOT WIN32 AND NOT DEFINED CACHE{HAVE_CLOCK_GETTIME})
# when clock_gettime is available.
add_compile_definitions(
HAVE_CLOCK_GETTIME
- HAVE_DECL_CLOCK_MONOTONIC=$<BOOL:${HAVE_DECL_CLOCK_MONOTONIC}>
+ HAVE_DECL_CLOCK_MONOTONIC=$<BOOL:"${HAVE_DECL_CLOCK_MONOTONIC}">
)
endif()
endif()
@@ -167,7 +167,7 @@ else()
# Check if pthread_condattr_setclock() exists to use CLOCK_MONOTONIC.
if(HAVE_DECL_CLOCK_MONOTONIC)
- list(INSERT CMAKE_REQUIRED_LIBRARIES 0 ${CMAKE_THREAD_LIBS_INIT})
+ list(INSERT CMAKE_REQUIRED_LIBRARIES 0 "${CMAKE_THREAD_LIBS_INIT}")
check_symbol_exists(pthread_condattr_setclock pthread.h
HAVE_PTHREAD_CONDATTR_SETCLOCK)
tuklib_add_definition_if(ALL HAVE_PTHREAD_CONDATTR_SETCLOCK)
@@ -395,11 +395,11 @@ if(WIN32)
elseif(CMAKE_SYSTEM_NAME MATCHES "^Linux$|^FreeBSD$")
# Symbol versioning for shared liblzma. This doesn't affect static builds.
target_link_options(liblzma PRIVATE
- -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map
+ "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map"
)
set_target_properties(liblzma PROPERTIES
- LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map
- LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc
+ LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma.map"
+ LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc"
)
endif()
@@ -407,8 +407,8 @@ set_target_properties(liblzma PROPERTIES
# At least for now the package versioning matches the rules used for
# shared library versioning (excluding development releases) so it is
# fine to use the package version here.
- SOVERSION ${xz_VERSION_MAJOR}
- VERSION ${xz_VERSION}
+ SOVERSION "${xz_VERSION_MAJOR}"
+ VERSION "${xz_VERSION}"
# It's liblzma.so or liblzma.dll, not libliblzma.so or lzma.dll.
# Avoid the name lzma.dll because it would conflict with LZMA SDK.
@@ -421,12 +421,12 @@ set_target_properties(liblzma PROPERTIES
# for development releases where each release may have incompatible changes.
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfigVersion.cmake
- VERSION ${liblzma_VERSION}
+ "${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfigVersion.cmake"
+ VERSION "${liblzma_VERSION}"
COMPATIBILITY SameMajorVersion)
# Create liblzmaConfig.cmake.
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfig.cmake
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfig.cmake"
"include(CMakeFindDependencyMacro)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_dependency(Threads)
@@ -439,36 +439,36 @@ include(GNUInstallDirs)
# Install the library binary. The INCLUDES specifies the include path that
# is exported for other projects to use but it doesn't install any files.
install(TARGETS liblzma EXPORT liblzmaTargets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT liblzma_Runtime
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT liblzma_Runtime
NAMELINK_COMPONENT liblzma_Development
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT liblzma_Development
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# Install the liblzma API headers. These use a subdirectory so
# this has to be done as a separate step.
install(DIRECTORY src/liblzma/api/
COMPONENT liblzma_Development
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.h")
# Install the CMake files that other packages can use to find liblzma.
set(liblzma_INSTALL_CMAKEDIR
- ${CMAKE_INSTALL_LIBDIR}/cmake/liblzma
+ "${CMAKE_INSTALL_LIBDIR}/cmake/liblzma"
CACHE STRING "Path to liblzma's .cmake files")
install(EXPORT liblzmaTargets
NAMESPACE liblzma::
FILE liblzmaTargets.cmake
- DESTINATION ${liblzma_INSTALL_CMAKEDIR}
+ DESTINATION "${liblzma_INSTALL_CMAKEDIR}"
COMPONENT liblzma_Development)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfig.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfigVersion.cmake
- DESTINATION ${liblzma_INSTALL_CMAKEDIR}
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/liblzmaConfigVersion.cmake"
+ DESTINATION "${liblzma_INSTALL_CMAKEDIR}"
COMPONENT liblzma_Development)
@@ -507,12 +507,12 @@ if(HAVE_GETOPT_LONG)
tuklib_progname(xzdec)
install(TARGETS xzdec
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT xzdec)
if(UNIX)
install(FILES src/xzdec/xzdec.1
- DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+ DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
COMPONENT xzdec)
endif()
endif()
@@ -634,10 +634,10 @@ if(NOT MSVC AND HAVE_GETOPT_LONG)
endif()
install(TARGETS xz
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT xz)
install(FILES src/xz/xz.1
- DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+ DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
COMPONENT xz)
endif()