From db20fb6ca175a72da5e0c4faefdba78b8641c268 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 30 Jul 2020 16:44:36 -0700 Subject: [PATCH] Fixes for using CMake with Visual Studio. Improvements to documentation for portability. --- CMakeLists.txt | 14 +++++++++++--- INSTALL | 9 +++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c093cef..b35c774c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ # $ mkdir build # $ cd build # $ cmake .. -# $ make +# $ cmake --build . # To build library only and not build examples and test apps use: # $ cmake .. -DBUILD_TESTS=NO @@ -89,12 +89,18 @@ file(GLOB TEST_SOURCE_FILES #################################################### # Output Files #################################################### -# DH requires math (m) library -link_libraries(m) # Build wolfssl library add_library(wolfssl ${LIB_SOURCE_FILES}) +if(WIN32) + # For Windows link ws2_32 + target_link_libraries(wolfssl PUBLIC $<$:ws2_32>) +else() + # DH requires math (m) library + target_link_libraries(wolfssl PUBLIC m) +endif() + # Optionally build example and test applications if(BUILD_TESTS) # Build wolfCrypt test @@ -140,3 +146,5 @@ if(BUILD_TESTS) target_link_libraries(unit_test wolfssl) target_link_libraries(unit_test Threads::Threads) endif() + +# TODO: Add install() for library, headers and test applications diff --git a/INSTALL b/INSTALL index 1aa12c69b..33a983ed7 100644 --- a/INSTALL +++ b/INSTALL @@ -85,8 +85,8 @@ $ mkdir build $ cd build $ cmake .. - $ make - $ sudo make install + $ cmake --build . + $ cmake --install . To build library only and not build examples and test apps use: $ cmake .. -DBUILD_TESTS=NO @@ -95,3 +95,8 @@ $ cmake .. -DCMAKE_BUILD_TYPE=Debug Make sure and run the built examples and test from the wolfssl-root to properly find the ./certs directory. + + CMake on Windows with Visual Studio + 1. Open Command Prompt + 2. Run the Visual Studio batch to setup command line variables: Example: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat + 3. Then use steps above