From 7f1fb955662d0df4425db0322b1fd3037edf42f1 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Thu, 20 Apr 2017 15:46:44 -0700 Subject: [PATCH] CMake: namespace modules and set CMAKE_MODULE_PATH --- build/cmake/CMakeLists.txt | 5 +++-- ...aCompilationFlags.cmake => AddZstdCompilationFlags.cmake} | 4 ++-- .../{GetLibraryVersion.cmake => GetZstdLibraryVersion.cmake} | 2 +- build/cmake/contrib/gen_html/CMakeLists.txt | 4 ++-- build/cmake/lib/CMakeLists.txt | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) rename build/cmake/CMakeModules/{AddExtraCompilationFlags.cmake => AddZstdCompilationFlags.cmake} (98%) rename build/cmake/CMakeModules/{GetLibraryVersion.cmake => GetZstdLibraryVersion.cmake} (86%) diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 0aa7b307..5c4eca61 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -10,12 +10,13 @@ PROJECT(zstd) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) SET(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") +LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") #----------------------------------------------------------------------------- # Add extra compilation flags #----------------------------------------------------------------------------- -INCLUDE(CMakeModules/AddExtraCompilationFlags.cmake) -ADD_EXTRA_COMPILATION_FLAGS() +INCLUDE(AddZstdCompilationFlags) +ADD_ZSTD_COMPILATION_FLAGS() #----------------------------------------------------------------------------- # Options diff --git a/build/cmake/CMakeModules/AddExtraCompilationFlags.cmake b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake similarity index 98% rename from build/cmake/CMakeModules/AddExtraCompilationFlags.cmake rename to build/cmake/CMakeModules/AddZstdCompilationFlags.cmake index e099a01d..177db541 100644 --- a/build/cmake/CMakeModules/AddExtraCompilationFlags.cmake +++ b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake @@ -19,7 +19,7 @@ function(EnableCompilerFlag _flag _C _CXX) endif () endfunction() -MACRO(ADD_EXTRA_COMPILATION_FLAGS) +MACRO(ADD_ZSTD_COMPILATION_FLAGS) if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW #Set c++11 by default EnableCompilerFlag("-std=c++11" false true) @@ -95,4 +95,4 @@ MACRO(ADD_EXTRA_COMPILATION_FLAGS) set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}" CACHE STRING "Updated flags" FORCE) set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE STRING "Updated flags" FORCE) -ENDMACRO(ADD_EXTRA_COMPILATION_FLAGS) +ENDMACRO(ADD_ZSTD_COMPILATION_FLAGS) diff --git a/build/cmake/CMakeModules/GetLibraryVersion.cmake b/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake similarity index 86% rename from build/cmake/CMakeModules/GetLibraryVersion.cmake rename to build/cmake/CMakeModules/GetZstdLibraryVersion.cmake index 95d84a89..8b6f394d 100644 --- a/build/cmake/CMakeModules/GetLibraryVersion.cmake +++ b/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake @@ -1,4 +1,4 @@ -function(GetLibraryVersion _header _major _minor _release) +function(GetZstdLibraryVersion _header _major _minor _release) # Read file content FILE(READ ${_header} CONTENT) diff --git a/build/cmake/contrib/gen_html/CMakeLists.txt b/build/cmake/contrib/gen_html/CMakeLists.txt index dff8c7a1..c10c62b5 100644 --- a/build/cmake/contrib/gen_html/CMakeLists.txt +++ b/build/cmake/contrib/gen_html/CMakeLists.txt @@ -11,7 +11,7 @@ # ################################################################ PROJECT(gen_html) -INCLUDE(${CMAKE_SOURCE_DIR}/CMakeModules/GetLibraryVersion.cmake) +INCLUDE(GetZstdLibraryVersion) SET(CMAKE_INCLUDE_CURRENT_DIR TRUE) @@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${GENHT ADD_EXECUTABLE(gen_html ${GENHTML_DIR}/gen_html.cpp) -GetLibraryVersion(${LIBRARY_DIR}/zstd.h VMAJOR VMINOR VRELEASE) +GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h VMAJOR VMINOR VRELEASE) SET(LIBVERSION "${VMAJOR}.${VMINOR}.${VRELEASE}") ADD_CUSTOM_TARGET(zstd_manual.html ALL ${GENHTML_BINARY} "${LIBVERSION}" "${LIBRARY_DIR}/zstd.h" "${PROJECT_BINARY_DIR}/zstd_manual.html" diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index 5e945ff1..937ddbc5 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -11,7 +11,6 @@ # ################################################################ PROJECT(libzstd) -INCLUDE(${CMAKE_SOURCE_DIR}/CMakeModules/GetLibraryVersion.cmake) SET(CMAKE_INCLUDE_CURRENT_DIR TRUE) OPTION(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" OFF) @@ -21,7 +20,8 @@ SET(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) INCLUDE_DIRECTORIES(${LIBRARY_DIR} ${LIBRARY_DIR}/common) # Parse version -GetLibraryVersion(${LIBRARY_DIR}/zstd.h LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE) +INCLUDE(GetZstdLibraryVersion) +GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE) MESSAGE("ZSTD VERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}") SET(Sources