[WIP] Feature: Adding CMake support - #48
Conversation
| ENDIF() | ||
|
|
||
| FILE(GLOB detours_src | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/*.h |
There was a problem hiding this comment.
Could you alphabetize the list of files here? I believe some source files are missing from the list. Also, please list out the header files - don't use the *.h pattern.
There was a problem hiding this comment.
Thank you for your suggestions!
Since I'm not quite familiar with the Detours itself, I just use the script then it builded successfully. I will sort all these files here.
Then you're right, it is not nesscessary to add the header files. I'll remove the pattern, and use INCLUDE_DIRECTORIES instead.
|
Thanks for the proposed change. I have some suggestions. |
|
Since the |
|
It looks like Detours relies on build order of sources to compile reliable (AFAIS detours.cpp should be first). However, this is pretty bad as VS doesn't guarantee build order of source files. I assume this is the reason your CMake file doesn't work for me. I guess your CMake configuration works for just one specific build order which I'm not getting on my machine. You are defining a lot of stuff which shouldn't be defined at all (e.g. DETOURS_VERSION, Please note that the nmake Makefile is only passing My own CMake configuration is working with these two definitions, too. I have put detours.cpp at first entry in the source list. However, I'm not sure if this is reproducible or just luck. I guess the correct approach would be to refactor Detours so it isn't dependent on build order anymore. |
|
I can't agree more! My approach is now just for forcing to make specific platform work, to meet my basic need. I have been trying to do some research about the cross platform/architecture problem these days. We need a more uniform design. |
|
Steven Hangger (@LonghronShen), what is the status of this change? We do need a cmake configuration to work for different developers. Are there dependencies missing from the cmake file that would better express the build order? |
|
Now the PR has been done for the main project, and several other example projects. |
|
I think it is fine to exclude some samples for now from the cmake build. We can merge the PR and that can be worked on later. Please make sure it is documented that those samples don't have a cmake build yet. |
CMake supportCMake support for the main project has been done for a while, but some sample projects are excluded for some interop reasons.
Other TODOs:
|
|
Please let me know when this is ready for further review. |
|
I think the current version is ready for review, except for these excluded sample projects. |
| LIST(APPEND DETOURS_COMPILE_DEFINITIONS "DETOURS_TARGET_PROCESSOR=X64") | ||
| LIST(APPEND DETOURS_COMPILE_DEFINITIONS DETOURS_X64) | ||
| LIST(APPEND DETOURS_COMPILE_DEFINITIONS DETOURS_64BIT) | ||
| LIST(APPEND DETOURS_COMPILE_DEFINITIONS _AMD64_) |
There was a problem hiding this comment.
The MSVC compiler sets these based on the architecture the configured compiler is targeting, the build system shouldn't be setting it them selves.
There was a problem hiding this comment.
This is just imitating the actions written in Makefiles. Or can we change the code so that we can use modern ways to check these staffs?
| ## | ||
|
|
||
| ## This file is based on the work of SimpleITK: | ||
| ## https://github.com/SimpleITK/SimpleITK/blob/master/CMake/FindCSharp.cmake |
There was a problem hiding this comment.
We can't copy and paste code from other projects into Detours, this code has it's own LICENSE.
There was a problem hiding this comment.
For this, I'll see if we can solve the problem by referencing the third party staffs as submodule or some other ways...
There was a problem hiding this comment.
CMake 3.8+ has native support for C#
See: https://cmake.org/cmake/help/latest/release/3.8.html#id4
| @@ -0,0 +1,79 @@ | |||
| CMAKE_MINIMUM_REQUIRED(VERSION 3.10) | |||
There was a problem hiding this comment.
Why is everything in all caps? can we fix it to be lower case?
There was a problem hiding this comment.
As for older cmake code style, commands are written in UPPER CASE. Now it is year 2020, I'll change this.
There was a problem hiding this comment.
I can run https://github.com/cheshirekow/cmake_format on the files if I can get push access to this PR.
|
Can you fix the merge conflicts in .gitignore? |
|
OK, I'll take it in the next one or two days. |
Yup, completely agree, and that's why I haven't merged this yet. |
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. |
|
last post was Sep 13, 2021, is this still an ongoing effort or has cmake been abandoned? |
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Successor to microsoft#48
Replaces the NMake Makefiles and vc/Detours.sln with a single CMake build covering the library, unit/integration tests, and every sample NMake built (opengl excluded, as NMake never built it either). find_package(Detours) is supported and tested against a real staged install, not just an in-tree build. .github/workflows/cmake.yml replaces main.yml's NMake-driven CI with a matrix across VS2022/VS2026, Ninja, x86/x64, Debug/Release, plus a real-hardware ARM64EC job, and keeps CodeQL coverage. NMake and the VS project are removed outright now that CMake has full parity, per the maintainer's own note that CMake would obsolete both: microsoft#48 (comment) Successor to microsoft#48
Replaces the NMake Makefiles and vc/Detours.sln with a single CMake build covering the library, unit/integration tests, and every sample NMake built (opengl excluded, as NMake never built it either). find_package(Detours) is supported and tested against a real staged install, not just an in-tree build. .github/workflows/cmake.yml replaces main.yml's NMake-driven CI with a matrix across VS2022/VS2026, Ninja, x86/x64, Debug/Release, plus a real-hardware ARM64EC job, and keeps CodeQL coverage. NMake and the VS project are removed outright now that CMake has full parity, per the maintainer's own note that CMake would obsolete both: microsoft#48 (comment) Successor to microsoft#48
|
I've made #390 based on the feedback in this PR and my knowledge of modern CMake. I also did my best to add fair bit of testing. We use detours in several projects for open source and at my company so we would like to get proper CMake support |
Looks like this effort was abandoned so I made a new one.
I've done my best to make the new CMake branch feature complete Brian Gianforcaro (@bgianfo) |
|
I ran a fair bit of testing on my fork to make sure everything was working properly |
|
As well as locally of course |
Try to add a simple CMakeLists.txt for building detours in x86/x64.
Support for other architectures like ARM/ARM64/IA64 may be added later.