-
Notifications
You must be signed in to change notification settings - Fork 55
[Work in Progress] Enable CMake build on Windows #1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
lalitb
wants to merge
16
commits into
main
Choose a base branch
from
cmake-windows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f331825
initial commit for building through CMake in Windows
lalitb 57f0157
remove debug code
lalitb 71d0f79
more unwanted code
lalitb 5530c78
fix
lalitb 88ba901
more changes
lalitb 224c84f
fix
lalitb 03bf8b0
fix unit-test
lalitb 43c5b3b
reorg
lalitb 4078cd9
reorg
lalitb de97be5
document build steps
lalitb 257ffd1
update prerequisite
lalitb a1aabdf
Merge branch 'main' into cmake-windows
ThomsonTan 8d3ff34
Merge branch 'main' into cmake-windows
sid-dahiya a0b2f62
Merge branch 'main' into cmake-windows
sid-dahiya 31cf757
Merge branch 'main' into cmake-windows
lalitb eb5679c
remove forced installation of dependencies for windows
lalitb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Building 1DS C++ SDK with cmake on Windows | ||
|
||
### Pre-requisite: | ||
|
||
- VS 2017/2019 | ||
- Chocolatey Package Manager | ||
- CMake 3.1.0 or higher | ||
|
||
### Steps: | ||
|
||
1. Clone the repo | ||
|
||
PS C:\> git clone https://github.com/microsoft/cpp_client_telemetry.git | ||
|
||
|
||
2. Fetch the submodules (specifically the vcpkg port): | ||
|
||
PS C:\cpp_client_telemetry> git submodule update --init | ||
|
||
3. Create CMake configuration | ||
|
||
PS C:\cpp_client_telemetry> mkdir build | ||
PS C:\cpp_client_telemetry> cd build | ||
PS C:\cpp_client_telemetry\build> cmake -DCMAKE_TOOLCHAIN_FILE=..\tools\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows .. | ||
|
||
4. Run CMake build | ||
|
||
PS C:\cpp_client_telemetry\build> cmake --build . | ||
|
||
This should build the 1DS C++ library, along with the functional and unit tests in `build` folder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add instructions on how to add it to another projects CMake as well? Like |
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
include_directories(. ${CMAKE_CURRENT_SOURCE_DIR}/../lib/include/public ${CMAKE_CURRENT_SOURCE_DIR}/../lib/include/mat ${CMAKE_CURRENT_SOURCE_DIR}/../lib/decoder ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite ) | ||
|
||
include_directories( | ||
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/googletest/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/googlemock/include | ||
) | ||
message("-->Lalit tests") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove? |
||
|
||
include_directories(../lib) | ||
|
||
|
@@ -14,10 +10,49 @@ set(TESTS_COMMON_SRCS | |
../../lib/decoder/PayloadDecoder.cpp | ||
) | ||
|
||
if (BUILD_FUNC_TESTS OR BUILD_UNIT_TEST) | ||
if (WIN32 AND CMAKE_TOOLCHAIN_FILE) | ||
find_package(gtest REQUIRED) | ||
find_package(SQLite3 REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
# GMOCK is not included as part of GTEST package installed through vcpkg, | ||
# so needs to be configured separately | ||
find_library(GOOGLE_MOCK gmock REQUIRED) | ||
find_library(GOOGLE_MOCK_MAIN gmock_main REQUIRED) | ||
find_library(GOOGLE_MOCKD gmockd REQUIRED) | ||
find_library(GOOGLE_MOCK_MAIND gmock_maind REQUIRED) | ||
|
||
# GMOCK doesn't work with static linking. | ||
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY) | ||
|
||
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}") | ||
message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}") | ||
message("GOOGLE_MOCK = ${GOOGLE_MOCK} ${GOOGLE_MOCK_MAIN}") | ||
message("SQLite3_LIBRARIES = ${SQLite3_LIBRARIES} ${SQLite3_INCLUDE_DIRS}") | ||
message("ZLIB_LIBRARIES = ${ZLIB_LIBRARIES}") | ||
|
||
#Include headers to be used both for unit and functional tests | ||
include_directories( ${GTEST_INCLUDE_DIRS} ) | ||
include_directories( ${GMOCK_INCLUDE_DIRS} ) | ||
include_directories( ${ZLIB_INCLUDE_DIRS} ) | ||
include_directories(${SQLite3_INCLUDE_DIRS} ) | ||
|
||
else() | ||
message("Adding gtest") | ||
add_library(gtest STATIC IMPORTED GLOBAL) | ||
message("Adding gmock") | ||
add_library(gmock STATIC IMPORTED GLOBAL) | ||
include_directories( | ||
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/googletest/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/googlemock/include | ||
) | ||
endif() | ||
endif() | ||
|
||
if(BUILD_FUNC_TESTS) | ||
add_subdirectory(functests) | ||
endif() | ||
|
||
if(BUILD_UNIT_TESTS) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/unittests) | ||
add_subdirectory(unittests) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: what is the reason to check for
NOT WIN32
- was it failing something if you don't add it? I wonder if we could eventually add logic in here under theif (BUILD_PACKAGE)
to produce a package, e.g. nuget or alike, even if we build on Windows. My selfish interest - is we'd likely need this CMake flow for our organization telemetry.