Browse Source

Fixes for using CMake with Visual Studio. Improvements to documentation for portability.

David Garske 3 years ago
parent
commit
db20fb6ca1
2 changed files with 18 additions and 5 deletions
  1. 11 3
      CMakeLists.txt
  2. 7 2
      INSTALL

+ 11 - 3
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 $<$<PLATFORM_ID:Windows>: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

+ 7 - 2
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