-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[WIP] Feature: Adding CMake support #48
base: main
Are you sure you want to change the base?
Conversation
CMakeLists.txt
Outdated
ENDIF() | ||
|
||
FILE(GLOB detours_src | ||
${CMAKE_CURRENT_LIST_DIR}/src/*.h |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is everything in all caps? can we fix it to be lower case?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@LonghronShen can you enable "Allow edits from Maintainer" for this PR? I have some fixes / additions locally that I would like to include before we merge this PR. Thanks! |
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. |
Any update on this? |
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. |
Any chance of this getting merged? |
Yea it's on my backlog of things to do. Since the author doesn't seem available, I'm planning on cherry-picking their commits and then fixing them up, and pushing it once it's ready. Let me know if you are able / willing to help with that. |
Preferably we should use a single build system for the entire project, because maintaining several is a maintenance burden more than anything else. Since CMake can generate Visual Studio solutions, maybe ditch nmake and the .sln? |
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. |
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.