From e1bd84d7f3b3ffd25cf91a2d3d0790edde014ced Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sun, 18 Nov 2018 04:18:42 +0100 Subject: [PATCH] CMake: set PDB output directory, don't set default build type --- CMakeLists.txt | 8 +++++++- src/CMakeLists.txt | 6 ++---- src/Cedar/CMakeLists.txt | 6 ++++++ src/Mayaqua/CMakeLists.txt | 14 ++++++++++---- src/PenCore/CMakeLists.txt | 1 + src/hamcorebuilder/CMakeLists.txt | 7 +++++++ src/vpnbridge/CMakeLists.txt | 7 +++++++ src/vpnclient/CMakeLists.txt | 7 +++++++ src/vpncmd/CMakeLists.txt | 7 +++++++ src/vpncmgr/CMakeLists.txt | 1 + src/vpnserver/CMakeLists.txt | 7 +++++++ src/vpnsmgr/CMakeLists.txt | 1 + src/vpntest/CMakeLists.txt | 7 +++++++ 13 files changed, 70 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c6f5b7c..519d2a0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,13 @@ project(SoftEtherVPN LANGUAGES C ) -set(default_build_type "Release") +# 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") + set(BUILD_TYPE "Debug") +else() + set(BUILD_TYPE "Release") +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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 763bc2f4..f63de397 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,11 +16,9 @@ if(UNIX) endmacro(install_wrapper_script) endif() -if(CMAKE_BUILD_TYPE STREQUAL "Debug") +if(BUILD_TYPE STREQUAL "Debug") add_definitions(-D_DEBUG -DDEBUG) -endif() - -if(CMAKE_BUILD_TYPE STREQUAL "Release") +else() add_definitions(-DNDEBUG -DVPN_SPEED) endif() diff --git a/src/Cedar/CMakeLists.txt b/src/Cedar/CMakeLists.txt index 186f0662..c89b1d1a 100644 --- a/src/Cedar/CMakeLists.txt +++ b/src/Cedar/CMakeLists.txt @@ -20,6 +20,12 @@ set_target_properties(cedar ) if(WIN32) + set_target_properties(cedar + PROPERTIES + COMPILE_PDB_NAME "cedar" + COMPILE_PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) + target_include_directories(cedar PRIVATE winpcap) endif() diff --git a/src/Mayaqua/CMakeLists.txt b/src/Mayaqua/CMakeLists.txt index cd5df0a9..2c6f84a7 100644 --- a/src/Mayaqua/CMakeLists.txt +++ b/src/Mayaqua/CMakeLists.txt @@ -17,6 +17,12 @@ set_target_properties(mayaqua ) if(WIN32) + set_target_properties(mayaqua + PROPERTIES + COMPILE_PDB_NAME "mayaqua" + COMPILE_PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) + add_subdirectory(3rdparty/zlib) target_include_directories(mayaqua PRIVATE win32_inc) @@ -25,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_${CMAKE_BUILD_TYPE}" + HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/x64_${BUILD_TYPE}" ) find_library(LIB_CRYPTO NAMES libcrypto libeay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/x64_${CMAKE_BUILD_TYPE}" + HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/x64_${BUILD_TYPE}" ) else() find_library(LIB_SSL NAMES libssl ssleay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/Win32_${CMAKE_BUILD_TYPE}" + HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/Win32_${BUILD_TYPE}" ) find_library(LIB_CRYPTO NAMES libcrypto libeay32 - HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/Win32_${CMAKE_BUILD_TYPE}" + HINTS "${CMAKE_SOURCE_DIR}/src/BuildFiles/Library/vs2017/Win32_${BUILD_TYPE}" ) endif() diff --git a/src/PenCore/CMakeLists.txt b/src/PenCore/CMakeLists.txt index 0e77093d..eb579b47 100644 --- a/src/PenCore/CMakeLists.txt +++ b/src/PenCore/CMakeLists.txt @@ -9,6 +9,7 @@ set_target_properties(PenCore 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" + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) target_link_libraries(PenCore cedar mayaqua) diff --git a/src/hamcorebuilder/CMakeLists.txt b/src/hamcorebuilder/CMakeLists.txt index a4fb02d5..7a25e5c8 100644 --- a/src/hamcorebuilder/CMakeLists.txt +++ b/src/hamcorebuilder/CMakeLists.txt @@ -7,4 +7,11 @@ set_target_properties(hamcorebuilder RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp" ) +if(WIN32) + set_target_properties(hamcorebuilder + PROPERTIES + PDB_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/tmp" + ) +endif() + target_link_libraries(hamcorebuilder cedar mayaqua) diff --git a/src/vpnbridge/CMakeLists.txt b/src/vpnbridge/CMakeLists.txt index d5e47bd7..b57f4d83 100644 --- a/src/vpnbridge/CMakeLists.txt +++ b/src/vpnbridge/CMakeLists.txt @@ -13,6 +13,13 @@ set_target_properties(vpnbridge RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) +if(WIN32) + set_target_properties(vpnbridge + PROPERTIES + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) +endif() + target_link_libraries(vpnbridge cedar mayaqua) if(UNIX) diff --git a/src/vpnclient/CMakeLists.txt b/src/vpnclient/CMakeLists.txt index 0634b357..abf82ad2 100644 --- a/src/vpnclient/CMakeLists.txt +++ b/src/vpnclient/CMakeLists.txt @@ -13,6 +13,13 @@ set_target_properties(vpnclient RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) +if(WIN32) + set_target_properties(vpnclient + PROPERTIES + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) +endif() + target_link_libraries(vpnclient cedar mayaqua) if(UNIX) diff --git a/src/vpncmd/CMakeLists.txt b/src/vpncmd/CMakeLists.txt index a4da4e31..8087f09a 100644 --- a/src/vpncmd/CMakeLists.txt +++ b/src/vpncmd/CMakeLists.txt @@ -13,6 +13,13 @@ set_target_properties(vpncmd RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) +if(WIN32) + set_target_properties(vpncmd + PROPERTIES + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) +endif() + target_link_libraries(vpncmd cedar mayaqua) if(UNIX) diff --git a/src/vpncmgr/CMakeLists.txt b/src/vpncmgr/CMakeLists.txt index a3ee5bc4..9d4aa7be 100644 --- a/src/vpncmgr/CMakeLists.txt +++ b/src/vpncmgr/CMakeLists.txt @@ -17,6 +17,7 @@ set_target_properties(vpncmgr ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" LIBRARY_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) target_link_libraries(vpncmgr cedar mayaqua) diff --git a/src/vpnserver/CMakeLists.txt b/src/vpnserver/CMakeLists.txt index 87f8b0a1..81c4eb6c 100644 --- a/src/vpnserver/CMakeLists.txt +++ b/src/vpnserver/CMakeLists.txt @@ -13,6 +13,13 @@ set_target_properties(vpnserver RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) +if(WIN32) + set_target_properties(vpnserver + PROPERTIES + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) +endif() + target_link_libraries(vpnserver cedar mayaqua) if(UNIX) diff --git a/src/vpnsmgr/CMakeLists.txt b/src/vpnsmgr/CMakeLists.txt index 626633cd..8e79bd0e 100644 --- a/src/vpnsmgr/CMakeLists.txt +++ b/src/vpnsmgr/CMakeLists.txt @@ -17,6 +17,7 @@ set_target_properties(vpnsmgr ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" LIBRARY_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) target_link_libraries(vpnsmgr cedar mayaqua) diff --git a/src/vpntest/CMakeLists.txt b/src/vpntest/CMakeLists.txt index ed30de26..9e3dde20 100644 --- a/src/vpntest/CMakeLists.txt +++ b/src/vpntest/CMakeLists.txt @@ -17,4 +17,11 @@ set_target_properties(vpntest RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) +if(WIN32) + set_target_properties(vpntest + PROPERTIES + PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" + ) +endif() + target_link_libraries(vpntest cedar mayaqua)