From 029ccc68ed1468baa840b785709b62eaf4fa9b23 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 19:11:13 +0200 Subject: [PATCH 1/7] Update CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR I've updated the CMAKE_SOURCE_DIR references to CMAKE_CURRENT_SOURCE_DIR to allow easier use of this code as a Git submodule. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a316b76..2ca20cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,11 +21,11 @@ set( PROJECT_DESCRIPTION "${EXTPKG_DESC}" CACHE PATH "Project description" FORCE # Load some handy CMake modules #------------------------------------------------------------------------------ -if( NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/modules" ) - message( FATAL_ERROR "CMake modules directory not found! ${CMAKE_SOURCE_DIR}/cmake/modules" ) +if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) + message( FATAL_ERROR "CMake modules directory not found! ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) else() - set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules" ) + set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) include( Vdump ) include( Trace ) @@ -76,7 +76,7 @@ check_header( stdint.h ) # defines HAVE_STDINT_H # Always generate the platform.h header #------------------------------------------------------------------------------ -if( NOT EXISTS ${CMAKE_SOURCE_DIR}/platform.h.in ) +if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform.h.in ) message( FATAL_ERROR "Unable to find platform.h.in!" ) else() configure_file( ${CMAKE_SOURCE_DIR}/platform.h.in From a4d2783eb968ae936a1d1ff352c007c69b5e3961 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 19:30:50 +0200 Subject: [PATCH 2/7] Update ParseBinaryDir to default to Release/64 Update ParseBinaryDir to default to 64-bit Release to allow being built in a more consistent fashion as part of eg a add_subdirectory() setup. --- cmake/modules/ParseBinaryDir.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/modules/ParseBinaryDir.cmake b/cmake/modules/ParseBinaryDir.cmake index 7983107..552dc3a 100644 --- a/cmake/modules/ParseBinaryDir.cmake +++ b/cmake/modules/ParseBinaryDir.cmake @@ -80,7 +80,10 @@ Remove the 'CMakeCache.txt' file and the entire 'CMakeFiles' directory and try a string( LENGTH ${CONFIG} _n ) if( ${_n} LESS 1 ) - message( FATAL_ERROR "Invalid Release/Debug build type! ${CONFIG}" ) + message( WARNING "Invalid Release/Debug build type! ${CONFIG}" ) + message( WARNING "Defaulting to Release_64" ) + set ( CONFIG "Release" ) + set ( LENGTH "_64" ) endif() #-------------------------------------------------------------------------- From ff92d11b2978898e102505ae66964c3a10bb8f38 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 19:48:12 +0200 Subject: [PATCH 3/7] Update ParseBinaryDir to fall back to the right module name Update ParseBinaryDir to fall back to the right module name, as well as change the cmakelist and includes to only reference the current project instead of the global project. --- CMakeLists.txt | 2 +- cmake/modules/ParseBinaryDir.cmake | 14 +++++++++----- includes.txt | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ca20cb..f4a6a58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ check_header( stdint.h ) # defines HAVE_STDINT_H if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform.h.in ) message( FATAL_ERROR "Unable to find platform.h.in!" ) else() - configure_file( ${CMAKE_SOURCE_DIR}/platform.h.in + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/platform.h.in ${CMAKE_BINARY_DIR}/platform.h ) endif() diff --git a/cmake/modules/ParseBinaryDir.cmake b/cmake/modules/ParseBinaryDir.cmake index 552dc3a..4d82991 100644 --- a/cmake/modules/ParseBinaryDir.cmake +++ b/cmake/modules/ParseBinaryDir.cmake @@ -82,8 +82,7 @@ Remove the 'CMakeCache.txt' file and the entire 'CMakeFiles' directory and try a if( ${_n} LESS 1 ) message( WARNING "Invalid Release/Debug build type! ${CONFIG}" ) message( WARNING "Defaulting to Release_64" ) - set ( CONFIG "Release" ) - set ( LENGTH "_64" ) + set( CONFIG "Release" ) endif() #-------------------------------------------------------------------------- @@ -95,7 +94,9 @@ Remove the 'CMakeCache.txt' file and the entire 'CMakeFiles' directory and try a Capitalize_Word( ${CONFIG} CONFIG ) if(( NOT CONFIG STREQUAL "Debug" ) AND (NOT CONFIG STREQUAL "Release" )) - message( FATAL_ERROR "Invalid Release/Debug build type! ${CONFIG}" ) + message( WARNING "Invalid Release/Debug build type! ${CONFIG}" ) + message( WARNING "Defaulting to Release_64" ) + set( CONFIG "Release" ) endif() #-------------------------------------------------------------------------- @@ -119,7 +120,7 @@ Remove the 'CMakeCache.txt' file and the entire 'CMakeFiles' directory and try a string( LENGTH ${_xxxxx} _n ) if( ${_n} LESS 3 ) - message( FATAL_ERROR "Invalid base package name! ${_xxxxx}" ) + message( WARNING "Invalid base package name! ${_xxxxx}" ) endif() math( EXPR _n "${_n} - 2" ) # (want the last two characters) @@ -129,7 +130,10 @@ Remove the 'CMakeCache.txt' file and the entire 'CMakeFiles' directory and try a if( NOT BITNESS STREQUAL "32" AND NOT BITNESS STREQUAL "64" ) - message( FATAL_ERROR "Invalid package architecture! ${BITNESS}" ) + message( WARNING "Invalid package architecture! ${BITNESS}" ) + message( WARNING "Defaulting to 64-bit" ) + set( BITNESS "64" ) + set( BASENAME "crypto" ) endif() #-------------------------------------------------------------------------- diff --git a/includes.txt b/includes.txt index df3c9b0..413f5dc 100644 --- a/includes.txt +++ b/includes.txt @@ -5,7 +5,7 @@ include_directories( BEFORE ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include ) #------------------------------------------------------------------------------ From 66cf3edabc22fc26951509d1fe9299efa2f8f230 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 20:00:24 +0200 Subject: [PATCH 4/7] Use defined constant instead of hardcoded value Use the EXTPKG_NAME constant instead of 'crypto' --- cmake/modules/ParseBinaryDir.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/ParseBinaryDir.cmake b/cmake/modules/ParseBinaryDir.cmake index 4d82991..3acc664 100644 --- a/cmake/modules/ParseBinaryDir.cmake +++ b/cmake/modules/ParseBinaryDir.cmake @@ -133,7 +133,7 @@ Remove the 'CMakeCache.txt' file and the entire 'CMakeFiles' directory and try a message( WARNING "Invalid package architecture! ${BITNESS}" ) message( WARNING "Defaulting to 64-bit" ) set( BITNESS "64" ) - set( BASENAME "crypto" ) + set( BASENAME ${EXTPKG_NAME} ) endif() #-------------------------------------------------------------------------- From d1beb93b9c06b4823c22aa8e0ace8e98f194f707 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 20:02:59 +0200 Subject: [PATCH 5/7] Add current binary dir as opposed to binary dir Set the include path to CMAKE_CURRENT_BINARY_DIR as opposed to CMAKE_BINARY_DIR so it will always default to the curent project. --- includes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes.txt b/includes.txt index 413f5dc..7ff1999 100644 --- a/includes.txt +++ b/includes.txt @@ -4,7 +4,7 @@ include_directories( BEFORE - ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) From c403c3b12215e0a11c4cc14a673ef1695a8a2b5a Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 20:06:47 +0200 Subject: [PATCH 6/7] Rename uninstall target to ${EXTPKG_NAME}_uninstall Rename uninstall target to ${EXTPKG_NAME}_uninstall to avoid overriding the generic 'uninstall' target. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4a6a58..ba3f74a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" # Now simply define an uninstall target that will run the above script. -add_custom_target( uninstall +add_custom_target( ${EXTPKG_NAME}_uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ) From fb7dd6ff09ce76a31550dff1cc3bd940f8ac4975 Mon Sep 17 00:00:00 2001 From: Yvan Janssens Date: Sat, 4 Jun 2022 20:16:28 +0200 Subject: [PATCH 7/7] Missed a CMAKE_CURRENT_BINARY_DIR value. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba3f74a..ff648ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform.h.in ) message( FATAL_ERROR "Unable to find platform.h.in!" ) else() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/platform.h.in - ${CMAKE_BINARY_DIR}/platform.h ) + ${CMAKE_CURRENT_BINARY_DIR}/platform.h ) endif()