Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd CMake and CI support #5604
Add CMake and CI support #5604
Conversation
|
I'm really exited to see this! How can I build and test it? On my mac, I used:
And I got:
|
|
Weird, can you show me also the output of the configuration phase? I will do another PR to add status badges to the README and the documentation somewhere, but we should choose where. On osql-experimental it was in the README, but I see that in the old master it was in the docs on readthedocs. |
|
Actually, I'll do another commit here for the build guide, I'll put it in the README for now. On Windows the build tools are updated to Visual Studio 2019, they are fine, but when choosing the Desktop development with C++ Workload, on the right side also select MSVC v141. |
|
Looks like I'm grabbing python from system, and not brew? (I don't know that this needs to be perfect to merge. I know there's other work happening on the tool chain) Configure step:
|
|
Reviewing now! |
Those are pythons from brew actually, the System one would be under /System/Library/Frameworks/... I wonder why it does that, I just tried again locally with macOS and I previously also had a "personal" Azure Pipelines CI setup here https://dev.azure.com/smjert-test/CITest/_build/results?buildId=96 which builds fine, and it always had on osql-experimental. I wonder if it's just AWS throwing some errors while downloading? try:
print "Downloading..."
url_opener = urllib.URLopener()
url_opener.retrieve(url, destination_file)
except:
print "Failed to retrieve the file from the given url"
return 1Have you tried to build a second time (from scratch! so there's no doubt!) We could eventually add more debug information when it fails |
|
Requesting changes to solicit your opinion. In general this looks OK. A huge plus for reducing the confusion of the previous CMake implementation. One high-level concern I have is the sheer volume of CMake code within |
| # This source code is licensed in accordance with the terms specified in | ||
| # the LICENSE file found in the root directory of this source tree. | ||
|
|
||
| cmake_minimum_required(VERSION 3.13.3) |
theopolis
Jun 26, 2019
Member
Is this really the minimum version needed?
Is this really the minimum version needed?
Smjert
Jun 26, 2019
•
Author
Contributor
Yep, it's needed on Windows, to have the ability to create symlinks from CMake with its own command, it resolves an issue when VS2017 and VS2109 are installed together, it provides "target_link_options" command which is a massive improvement in how link flags are added.
In general this is a non-issue because you can download a pre-compiled binary from the CMake website, or compile it from scratch (which is not difficult at all and works pretty everywhere).
Yep, it's needed on Windows, to have the ability to create symlinks from CMake with its own command, it resolves an issue when VS2017 and VS2109 are installed together, it provides "target_link_options" command which is a massive improvement in how link flags are added.
In general this is a non-issue because you can download a pre-compiled binary from the CMake website, or compile it from scratch (which is not difficult at all and works pretty everywhere).
| cmake_minimum_required(VERSION 3.13.3) | ||
| project(osquery) | ||
|
|
||
| if (BUILD_TESTING) |
theopolis
Jun 26, 2019
Member
nitpick, inconsistent spacing if( and if used in places
nitpick, inconsistent spacing if( and if used in places
Smjert
Jun 26, 2019
Author
Contributor
👍
I'll do a pass to all the code for formatting issues.
I'll do a pass to all the code for formatting issues.
| message(STATUS "Shared libraries: ${BUILD_SHARED_LIBS}") | ||
|
|
||
| if (DEFINED PLATFORM_MACOS) | ||
| if((NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" AND NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") OR |
theopolis
Jun 26, 2019
Member
Does it make sense to break these out into set(APPLE_CLANG ... and LLVM_CLANG to make the conditional logic easier to read?
Does it make sense to break these out into set(APPLE_CLANG ... and LLVM_CLANG to make the conditional logic easier to read?
Smjert
Jun 26, 2019
Author
Contributor
Well I don't think we need to have variables to actually distinguish them, maybe that can be solved just checking once for Clang but using MATCHES which searches for the word in the string.
Well I don't think we need to have variables to actually distinguish them, maybe that can be solved just checking once for Clang but using MATCHES which searches for the word in the string.
| # This source code is licensed in accordance with the terms specified in | ||
| # the LICENSE file found in the root directory of this source tree. | ||
|
|
||
| cmake_minimum_required(VERSION 3.13.3) |
theopolis
Jun 26, 2019
Member
Should we only have a single required statement in the root CMakeLists.txt?
Should we only have a single required statement in the root CMakeLists.txt?
Smjert
Jun 26, 2019
Author
Contributor
👍
Victim of copy paste and force of habit
Victim of copy paste and force of habit
| elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | ||
| set(PLATFORM_WINDOWS 1) | ||
| else() | ||
| message(FATAL_ERROR "Unrecognized platform") |
theopolis
Jun 26, 2019
Member
nitpick, inconsistent spaces and tabs used for indent.
nitpick, inconsistent spaces and tabs used for indent.
| <PropertyRef Id="WIX_ACCOUNT_USERS" /> | ||
| <PropertyRef Id="WIX_ACCOUNT_ADMINISTRATORS" /> | ||
| </CPackWiXFragment> | ||
| </CPackWiXPatch> |
theopolis
Jun 26, 2019
Member
nit
nit
Smjert
Jun 26, 2019
Author
Contributor
What's the issue here?
What's the issue here?
Smjert
Jun 26, 2019
Author
Contributor
Ah I guess the spaces before />?
Ah I guess the spaces before />?
| # This source code is licensed in accordance with the terms specified in | ||
| # the LICENSE file found in the root directory of this source tree. | ||
|
|
||
| cmake_minimum_required(VERSION 3.13.3) |
theopolis
Jun 26, 2019
Member
ditto
ditto
| elseif(DEFINED PLATFORM_MACOS) | ||
| set(hash "7f9b44ca67eadb2c6dcf6b86688cb759b77b772858dae2a2380c032c7c1d9edd") | ||
| elseif(DEFINED PLATFORM_WINDOWS) | ||
| set(hash "1685157a99c419e5150cc5f44a61ad1a1f5ddf414bf1a451ed9b6c7faf26d4bc") |
theopolis
Jun 26, 2019
Member
nitpick, tab
nitpick, tab
|
|
||
| # Generates a target named identifier_downloader that will acquire the remote file while also verifying | ||
| # its hash | ||
| function(downloadRemoteFile identifier base_url file_name hash) |
theopolis
Jun 26, 2019
Member
I think we can remove a lot of the helper code here if we replace the dependency management in the future.
I think we can remove a lot of the helper code here if we replace the dependency management in the future.
|
|
||
| set(anchor_file "lib/libtesting-resources.a") | ||
|
|
||
| set(additional_libraries |
theopolis
Jun 26, 2019
Member
Any thoughts about how to make this more generic?
For example you are copy-pasting the library paths save for the {a,lib}.
Any thoughts about how to make this more generic?
For example you are copy-pasting the library paths save for the {a,lib}.
Smjert
Jun 26, 2019
•
Author
Contributor
Yeah, in general this can be simplified even more.
If we are sure that all the .a or .lib present in the pack are needed, we could just GLOB them and use the same "importThirdPartyBinaryLibrary" to generate all the needed targets.
EDIT:
Actually I'm misremembering the issue here.
Those files are not present at configure time, so they cannot be globbed, they still don't exists.
Now I think you originally just meant to have a single list of names with code that adds .a or .lib when necessary, right?
That can be simplified but I'm not sure if it's really worth..., also on Windows sometimes the libs have different names.
Yeah, in general this can be simplified even more.
If we are sure that all the .a or .lib present in the pack are needed, we could just GLOB them and use the same "importThirdPartyBinaryLibrary" to generate all the needed targets.
EDIT:
Actually I'm misremembering the issue here.
Those files are not present at configure time, so they cannot be globbed, they still don't exists.
Now I think you originally just meant to have a single list of names with code that adds .a or .lib when necessary, right?
That can be simplified but I'm not sure if it's really worth..., also on Windows sometimes the libs have different names.
Well boilerplate reduction is always welcome, though we have to be careful not to tailor it on the specific/current usage. Also to be fair, experimental has added a lot more libraries/targets to be built, with their own requirements, so there's more CMake code there. Probably there are places where one could group targets which are linked over and over, we didn't do that initially because targets where still changing a lot. I would also add that we kind of mirrored, where possible, the structure of the BUCK files. About adding a file to a library, that is just adding a line basically. EDIT: |
To better answer this: yes! definitely, I actually had a guide in the works to explain some of the specific choices done with CMake that are needed to stay as most "compatible" with BUCK as possible. Anyway I suppose that with file you meant, a new source code: that's easy. Comparing it to a change that doesn't come from BUCK, it's just a matter to find the CMakeLists.txt in the same folder where the change happened. Inside the file, it's all pretty structured and it should be easy to find where to add new source code file to be compiled with the library/executable. |
919958e
to
17aa19f
Taken from osql-experimental. Initial support for Linux and macOS.
Taken from osql-experimental. - Change CMake code license to the one present in osquery right now - Package metadata doesn't mention Trail of Bits or osql anymore - Set specific ACLs for the osqueryd on Windows when packaging - Remove LLVM_INSTALL_PATH support on macOS, since we are using AppleClang - Remove OSQUERY_SOURCE_DIR variable need and source in a submodule support - Add targets format_check and format to check code formatting and format it with clang-format - Do not warn about not using Clang on macOS when using AppleClang
Only define BOOST_ASIO_DISABLE_STD_STRING_VIEW. We shouldn't define BOOST_ASIO_HAS_STD_STRING_VIEW, because even if we define BOOST_ASIO_DISABLE_STD_STRING_VIEW the first define will actually enable parts of code that will use string_view. This won't work on Windows and in general, string_view should not be used unless compiling with C++17. The hack has been also added to a test that was previously missed.
Taken from osql-experimental. - Use AppleClang compiler for macOS - Run format_check on Linux - Run pipeline only on master
17aa19f
to
42bc51b
|
I've restored @alessandrogario initial commit for some due credits. |
ce5fee3
into
osquery:master
|
<3 this merged |
This PR restores CMake support, taken from osql-experimental and adapted to the use on this repository.
It gives a configuration file for Azure Pipelines, which includes a code formatting check on the Linux build.
It also fixes a build issue on Windows and macOS, related to the string_view/boost asio issue.
#5588