From 04188f860628efaaeb4c609b474ab1112e296130 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sun, 18 Nov 2018 23:13:59 +0000 Subject: [PATCH] CMake: change project name to "SoftEther VPN", create and use "TOP_DIRECTORY" variable --- CMakeLists.txt | 16 +++++++++------- src/CMakeLists.txt | 10 +++++----- src/Mayaqua/CMakeLists.txt | 8 ++++---- src/PenCore/CMakeLists.txt | 6 +++--- src/hamcorebuilder/CMakeLists.txt | 8 ++++---- src/vpnbridge/CMakeLists.txt | 2 +- src/vpnclient/CMakeLists.txt | 2 +- src/vpncmgr/CMakeLists.txt | 4 ++-- src/vpnserver/CMakeLists.txt | 2 +- src/vpnsmgr/CMakeLists.txt | 4 ++-- src/vpntest/CMakeLists.txt | 4 ++-- 11 files changed, 34 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f28c5f3..d192e03d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ cmake_minimum_required(VERSION 3.7) -project(SoftEtherVPN +project("SoftEther VPN" VERSION 5.01.9664 LANGUAGES C ) +set(TOP_DIRECTORY ${CMAKE_SOURCE_DIR}) +set(BUILD_DIRECTORY ${TOP_DIRECTORY}/build) + # We define a dedicated variable because CMAKE_BUILD_TYPE can have different # configurations than "Debug" and "Release", such as "RelWithDebInfo". if(CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -14,12 +17,12 @@ else() endif() # Check that submodules are present only if source was downloaded with git -if(EXISTS "${SoftEtherVPN_SOURCE_DIR}/.git" AND NOT EXISTS "${SoftEtherVPN_SOURCE_DIR}/src/Mayaqua/3rdparty/cpu_features/CMakeLists.txt") +if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/Mayaqua/3rdparty/cpu_features/CMakeLists.txt") message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive") endif() # Compare ${PROJECT_VERSION} and src/CurrentBuild.txt -file(READ ${SoftEtherVPN_SOURCE_DIR}/src/CurrentBuild.txt CurrentBuild) +file(READ ${TOP_DIRECTORY}/src/CurrentBuild.txt CurrentBuild) string(REGEX MATCH "VERSION_MAJOR ([0-9]+)" temp ${CurrentBuild}) string(REGEX REPLACE "VERSION_MAJOR ([0-9]+)" "\\1" CurrentBuild_MAJOR ${temp}) @@ -40,9 +43,8 @@ if(UNIX) Check_Include_File(sys/auxv.h HAVE_SYS_AUXV) endif() -configure_file("${SoftEtherVPN_SOURCE_DIR}/AUTHORS.TXT" "${SoftEtherVPN_SOURCE_DIR}/src/bin/hamcore/authors.txt" COPYONLY) +configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY) -set(BUILD_DIRECTORY ${SoftEtherVPN_SOURCE_DIR}/build) set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) add_subdirectory(src) @@ -54,11 +56,11 @@ if(UNIX) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_PACKAGE_VENDOR "SoftEther") set(CPACK_PACKAGE_NAME "softether") - set(CPACK_PACKAGE_DESCRIPTION_FILE "${SoftEtherVPN_SOURCE_DIR}/description") + set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_DIRECTORY}/description") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SoftEther VPN is an open-source cross-platform multi-protocol VPN program, created as an academic project in the University of Tsukuba.") # DEB - if(CMAKE_BUILD_TYPE STREQUAL "Debug") + if(BUILD_TYPE STREQUAL "Debug") set(CPACK_DEBIAN_PACKAGE_DEBUG ON) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f63de397..9f34aa06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,11 +4,11 @@ if(UNIX) macro(install_wrapper_script component target) get_filename_component(file_name ${target} NAME) - file(WRITE ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "#!/bin/sh\n") - file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "${target} \"$@\"\n") - file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "exit $?\n") + file(WRITE ${TOP_DIRECTORY}/tmp/script/${file_name} "#!/bin/sh\n") + file(APPEND ${TOP_DIRECTORY}/tmp/script/${file_name} "${target} \"$@\"\n") + file(APPEND ${TOP_DIRECTORY}/tmp/script/${file_name} "exit $?\n") - install(FILES ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} + install(FILES ${TOP_DIRECTORY}/tmp/script/${file_name} COMPONENT ${component} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE @@ -100,7 +100,7 @@ add_subdirectory(vpntest) # hamcore.se2 archive file add_custom_target(hamcore-archive-build ALL - COMMAND hamcorebuilder "${CMAKE_SOURCE_DIR}/src/bin/hamcore/" "${BUILD_DIRECTORY}/hamcore.se2" + COMMAND hamcorebuilder "${TOP_DIRECTORY}/src/bin/hamcore/" "${BUILD_DIRECTORY}/hamcore.se2" DEPENDS hamcorebuilder COMMENT "Building hamcore.se2 archive file..." VERBATIM diff --git a/src/Mayaqua/CMakeLists.txt b/src/Mayaqua/CMakeLists.txt index 2c6f84a7..8d1837e4 100644 --- a/src/Mayaqua/CMakeLists.txt +++ b/src/Mayaqua/CMakeLists.txt @@ -31,22 +31,22 @@ if(WIN32) if(${COMPILER_ARCHITECTURE} STREQUAL "x64") find_library(LIB_SSL NAMES libssl ssleay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/x64_${BUILD_TYPE}" + HINTS "${TOP_DIRECTORY}/src/BuildFiles/Library/vs2017/x64_${BUILD_TYPE}" ) find_library(LIB_CRYPTO NAMES libcrypto libeay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/x64_${BUILD_TYPE}" + HINTS "${TOP_DIRECTORY}/src/BuildFiles/Library/vs2017/x64_${BUILD_TYPE}" ) else() find_library(LIB_SSL NAMES libssl ssleay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/Win32_${BUILD_TYPE}" + HINTS "${TOP_DIRECTORY}/src/BuildFiles/Library/vs2017/Win32_${BUILD_TYPE}" ) find_library(LIB_CRYPTO NAMES libcrypto libeay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/Win32_${BUILD_TYPE}" + HINTS "${TOP_DIRECTORY}/src/BuildFiles/Library/vs2017/Win32_${BUILD_TYPE}" ) endif() diff --git a/src/PenCore/CMakeLists.txt b/src/PenCore/CMakeLists.txt index eb579b47..5cb3175c 100644 --- a/src/PenCore/CMakeLists.txt +++ b/src/PenCore/CMakeLists.txt @@ -6,9 +6,9 @@ add_library(PenCore SHARED pencore.c pencore.rc) set_target_properties(PenCore PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/src/bin/hamcore" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/src/bin/hamcore" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/src/bin/hamcore" + ARCHIVE_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/src/bin/hamcore" + LIBRARY_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/src/bin/hamcore" + RUNTIME_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/src/bin/hamcore" PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) diff --git a/src/hamcorebuilder/CMakeLists.txt b/src/hamcorebuilder/CMakeLists.txt index 7a25e5c8..3e8d7b3d 100644 --- a/src/hamcorebuilder/CMakeLists.txt +++ b/src/hamcorebuilder/CMakeLists.txt @@ -2,15 +2,15 @@ add_executable(hamcorebuilder hamcorebuilder.c) set_target_properties(hamcorebuilder PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp" + ARCHIVE_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/tmp" + LIBRARY_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/tmp" + RUNTIME_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/tmp" ) if(WIN32) set_target_properties(hamcorebuilder PROPERTIES - PDB_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp" + PDB_OUTPUT_DIRECTORY "${TOP_DIRECTORY}/tmp" ) endif() diff --git a/src/vpnbridge/CMakeLists.txt b/src/vpnbridge/CMakeLists.txt index b57f4d83..7f9ccc2d 100644 --- a/src/vpnbridge/CMakeLists.txt +++ b/src/vpnbridge/CMakeLists.txt @@ -38,7 +38,7 @@ if(UNIX) install_wrapper_script("vpnbridge" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnbridge/vpnbridge") if(EXISTS "/lib/systemd/system") - configure_file(${CMAKE_SOURCE_DIR}/systemd/softether-vpnbridge.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service) + configure_file(${TOP_DIRECTORY}/systemd/softether-vpnbridge.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service) install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service COMPONENT "vpnbridge" DESTINATION "/lib/systemd/system" diff --git a/src/vpnclient/CMakeLists.txt b/src/vpnclient/CMakeLists.txt index abf82ad2..709bd441 100644 --- a/src/vpnclient/CMakeLists.txt +++ b/src/vpnclient/CMakeLists.txt @@ -38,7 +38,7 @@ if(UNIX) install_wrapper_script("vpnclient" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnclient/vpnclient") if(EXISTS "/lib/systemd/system") - configure_file(${CMAKE_SOURCE_DIR}/systemd/softether-vpnclient.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service) + configure_file(${TOP_DIRECTORY}/systemd/softether-vpnclient.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service) install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service COMPONENT "vpnclient" DESTINATION "/lib/systemd/system" diff --git a/src/vpncmgr/CMakeLists.txt b/src/vpncmgr/CMakeLists.txt index 9d4aa7be..4b899338 100644 --- a/src/vpncmgr/CMakeLists.txt +++ b/src/vpncmgr/CMakeLists.txt @@ -5,9 +5,9 @@ endif() set(VPNCMGR_SOURCES vpncmgr.c vpncmgr.rc) if(${COMPILER_ARCHITECTURE} STREQUAL "x64") - set(VPNCMGR_SOURCES ${VPNCMGR_SOURCES} ${CMAKE_SOURCE_DIR}/src/BuildFiles/Manifests/x64_user.manifest) + set(VPNCMGR_SOURCES ${VPNCMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest) else() - set(VPNCMGR_SOURCES ${VPNCMGR_SOURCES} ${CMAKE_SOURCE_DIR}/src/BuildFiles/Manifests/x86_user.manifest) + set(VPNCMGR_SOURCES ${VPNCMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest) endif() add_executable(vpncmgr WIN32 ${VPNCMGR_SOURCES}) diff --git a/src/vpnserver/CMakeLists.txt b/src/vpnserver/CMakeLists.txt index 81c4eb6c..7841a0a9 100644 --- a/src/vpnserver/CMakeLists.txt +++ b/src/vpnserver/CMakeLists.txt @@ -38,7 +38,7 @@ if(UNIX) install_wrapper_script("vpnserver" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver") if(EXISTS "/lib/systemd/system") - configure_file(${CMAKE_SOURCE_DIR}/systemd/softether-vpnserver.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service) + configure_file(${TOP_DIRECTORY}/systemd/softether-vpnserver.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service) install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service COMPONENT "vpnserver" DESTINATION "/lib/systemd/system" diff --git a/src/vpnsmgr/CMakeLists.txt b/src/vpnsmgr/CMakeLists.txt index 8e79bd0e..049449b7 100644 --- a/src/vpnsmgr/CMakeLists.txt +++ b/src/vpnsmgr/CMakeLists.txt @@ -5,9 +5,9 @@ endif() set(VPNSMGR_SOURCES vpnsmgr.c vpnsmgr.rc) if(${COMPILER_ARCHITECTURE} STREQUAL "x64") - set(VPNSMGR_SOURCES ${VPNSMGR_SOURCES} ${CMAKE_SOURCE_DIR}/src/BuildFiles/Manifests/x64_user.manifest) + set(VPNSMGR_SOURCES ${VPNSMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest) else() - set(VPNSMGR_SOURCES ${VPNSMGR_SOURCES} ${CMAKE_SOURCE_DIR}/src/BuildFiles/Manifests/x86_user.manifest) + set(VPNSMGR_SOURCES ${VPNSMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest) endif() add_executable(vpnsmgr WIN32 ${VPNSMGR_SOURCES}) diff --git a/src/vpntest/CMakeLists.txt b/src/vpntest/CMakeLists.txt index 9e3dde20..b05f3892 100644 --- a/src/vpntest/CMakeLists.txt +++ b/src/vpntest/CMakeLists.txt @@ -2,9 +2,9 @@ set(VPNTEST_SOURCES vpntest.c vpntest.h) if(WIN32) if(${COMPILER_ARCHITECTURE} STREQUAL "x64") - set(VPNTEST_SOURCES ${VPNTEST_SOURCES} ${CMAKE_SOURCE_DIR}/src/BuildFiles/Manifests/x64_user.manifest) + set(VPNTEST_SOURCES ${VPNTEST_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest) else() - set(VPNTEST_SOURCES ${VPNTEST_SOURCES} ${CMAKE_SOURCE_DIR}/src/BuildFiles/Manifests/x86_user.manifest) + set(VPNTEST_SOURCES ${VPNTEST_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest) endif() endif()