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

This commit is contained in:
David Garske
2020-07-30 16:44:36 -07:00
parent 8b25b48621
commit db20fb6ca1
2 changed files with 18 additions and 5 deletions

View File

@ -8,7 +8,7 @@
# $ mkdir build # $ mkdir build
# $ cd build # $ cd build
# $ cmake .. # $ cmake ..
# $ make # $ cmake --build .
# To build library only and not build examples and test apps use: # To build library only and not build examples and test apps use:
# $ cmake .. -DBUILD_TESTS=NO # $ cmake .. -DBUILD_TESTS=NO
@ -89,12 +89,18 @@ file(GLOB TEST_SOURCE_FILES
#################################################### ####################################################
# Output Files # Output Files
#################################################### ####################################################
# DH requires math (m) library
link_libraries(m)
# Build wolfssl library # Build wolfssl library
add_library(wolfssl ${LIB_SOURCE_FILES}) 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 # Optionally build example and test applications
if(BUILD_TESTS) if(BUILD_TESTS)
# Build wolfCrypt test # Build wolfCrypt test
@ -140,3 +146,5 @@ if(BUILD_TESTS)
target_link_libraries(unit_test wolfssl) target_link_libraries(unit_test wolfssl)
target_link_libraries(unit_test Threads::Threads) target_link_libraries(unit_test Threads::Threads)
endif() endif()
# TODO: Add install() for library, headers and test applications

View File

@ -85,8 +85,8 @@
$ mkdir build $ mkdir build
$ cd build $ cd build
$ cmake .. $ cmake ..
$ make $ cmake --build .
$ sudo make install $ cmake --install .
To build library only and not build examples and test apps use: To build library only and not build examples and test apps use:
$ cmake .. -DBUILD_TESTS=NO $ cmake .. -DBUILD_TESTS=NO
@ -95,3 +95,8 @@
$ cmake .. -DCMAKE_BUILD_TYPE=Debug $ cmake .. -DCMAKE_BUILD_TYPE=Debug
Make sure and run the built examples and test from the wolfssl-root to properly find the ./certs directory. 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