Skip to content

Commit

Permalink
win: replace msvc project files with cmake
Browse files Browse the repository at this point in the history
Signed-off-by: Lev Stipakov <lev@openvpn.net>
  • Loading branch information
lstipakov authored and schwabe committed Jan 29, 2020
1 parent c53c42d commit 1c9834c
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 1,511 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ README.html
x64
*.vcxproj.user
*.ipch
out
.vs
.vscode
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Cmake in OpenVPN3 core is mainly used to get Clion editior support and to run unit tests. For normal
# Build instructions see the README.rst

project(OpenVPN3-core)
cmake_policy(SET CMP0048 NEW)
project(OpenVPN3-core VERSION 3)

cmake_minimum_required(VERSION 3.5)

add_subdirectory(test/unittests)
add_subdirectory(test/ovpncli)
add_subdirectory(test/ssl)


if (WIN32)
add_subdirectory(openvpn/omi)
endif ()

8 changes: 8 additions & 0 deletions cmake/dlgoogletest.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if (WIN32)
find_package(GTest CONFIG REQUIRED)
set(GTEST_LIB GTest::gtest_main)
else()

set(GTEST_LIB gtest_main)

# Google Test Unit testing
# Download and unpack googletest at configure time
Expand Down Expand Up @@ -33,3 +39,5 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)

endif ()
21 changes: 19 additions & 2 deletions cmake/findcoredeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ function(add_core_dependencies target)
-D_CRT_SECURE_NO_WARNINGS
)
set(EXTRA_LIBS fwpuclnt.lib Iphlpapi.lib Wininet.lib Setupapi.lib Rpcrt4.lib Wtsapi32.lib lz4::lz4)
if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
# by some reasons CMake doesn't add those for ARM64
list(APPEND EXTRA_LIBS advapi32.lib Ole32.lib Shell32.lib)
endif ()

target_compile_options(${target} PRIVATE "/bigobj")

find_package(lz4 CONFIG REQUIRED)
Expand Down Expand Up @@ -121,6 +126,18 @@ function(add_core_dependencies target)
target_compile_options(${target} PRIVATE -Wall -Wsign-compare)
endif()

endfunction()


endfunction()
function (add_json_library target)
if (WIN32)
find_package(jsoncpp CONFIG REQUIRED)
target_link_libraries(${target} jsoncpp_lib)
target_compile_definitions(${target} PRIVATE -DHAVE_JSONCPP)
message("Adding jsoncpp to " ${target})
else ()
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP jsoncpp)
target_link_libraries(${target} ${JSONCPP_LDFLAGS})
target_include_directories(${target} PRIVATE ${JSONCPP_INCLUDE_DIRS})
endif ()
endfunction ()
15 changes: 15 additions & 0 deletions openvpn/omi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.5)

project(omicli)
set(CMAKE_CXX_STANDARD 14)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake;${CMAKE_MODULE_PATH}")
include(findcoredeps)

add_executable(omicliagent openvpn.cpp)
add_core_dependencies(omicliagent)
add_json_library(omicliagent)
target_compile_definitions(omicliagent PRIVATE -DOPENVPN_COMMAND_AGENT)

add_executable(omicli openvpn.cpp)
add_core_dependencies(omicli)
9 changes: 8 additions & 1 deletion test/ovpncli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ if (${CLI_NULLTUN})
target_compile_definitions(ovpnclinull PRIVATE -DOPENVPN_FORCE_TUN_NULL)
endif ()


if (${CLI_DCO})
include(kovpn)

Expand All @@ -31,3 +30,11 @@ if (${CLI_DCO})
target_include_directories(ovpnclidco PRIVATE ${KOVPN_SOURCE})
target_compile_definitions(ovpnclidco PRIVATE -DENABLE_DCO)
endif ()

if (WIN32)
# for macos, agent-enabled client requires common and is built by scripts there
add_executable(ovpncliagent cli.cpp)
add_core_dependencies(ovpncliagent)
add_json_library(ovpncliagent)
target_compile_definitions(ovpncliagent PRIVATE -DOPENVPN_COMMAND_AGENT)
endif ()
2 changes: 1 addition & 1 deletion test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ set(CORE_TEST_DEFINES
add_executable(coreUnitTests ${SOURCES})

add_core_dependencies(coreUnitTests)
target_link_libraries(coreUnitTests gtest_main ${EXTRA_LIBS})
target_link_libraries(coreUnitTests ${GTEST_LIB} ${EXTRA_LIBS})

target_compile_definitions(coreUnitTests PRIVATE ${CORE_TEST_DEFINES})
target_include_directories(coreUnitTests PRIVATE ${EXTRA_INCLUDES})
Expand Down
116 changes: 0 additions & 116 deletions test/unittests/unittests.vcxproj

This file was deleted.

22 changes: 0 additions & 22 deletions test/unittests/unittests.vcxproj.filters

This file was deleted.

12 changes: 0 additions & 12 deletions win/.gitignore

This file was deleted.

64 changes: 0 additions & 64 deletions win/ovpn3-core.sln

This file was deleted.

Loading

0 comments on commit 1c9834c

Please sign in to comment.