Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

LonghronShen
Copy link

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.

@msftclas
Copy link

msftclas commented Dec 10, 2018

CLA assistant check
All CLA requirements met.

CMakeLists.txt Outdated
ENDIF()

FILE(GLOB detours_src
${CMAKE_CURRENT_LIST_DIR}/src/*.h
Copy link
Contributor

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.

Copy link
Author

@LonghronShen LonghronShen Jan 26, 2019

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.

@dtarditi
Copy link
Contributor

Thanks for the proposed change. I have some suggestions.

@LonghronShen
Copy link
Author

LonghronShen commented Jan 26, 2019

Since the uimports.cpp file is included in creatwth.cpp#L347, I suggest that the uimports.cpp file should be renamed to uimports.h, then we can use *.cpp pattern to add all source files in the CMakeLists.txt.
CMakeLists.txt for samples are on the way.
OK, including .cpp files happens many times in the samples. Will this be changed in the future?

@LonghronShen LonghronShen changed the title Add CMake support [WIP] Adding CMake support Jan 26, 2019
@schlamar
Copy link

schlamar commented Feb 4, 2019

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, _X86_, DETOURS_X86, etc.).

Please note that the nmake Makefile is only passing /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x501 to the compiler. (DETOURS_BITS=X is passed to rc.exe, but this is only relevant on building the examples).

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.

@LonghronShen
Copy link
Author

LonghronShen commented Feb 4, 2019

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.

@dtarditi
Copy link
Contributor

@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?

@LonghronShen
Copy link
Author

Now the PR has been done for the main project, and several other example projects.
What is still blocked is some example projects which involves some COM interops.
If this is not the key problem, I can update the PR and then I think we can merge the PR.

@dtarditi
Copy link
Contributor

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.

@LonghronShen
Copy link
Author

LonghronShen commented May 16, 2019

CMake support

CMake support for the main project has been done for a while, but some sample projects are excluded for some interop reasons.

  • cping
  • disas
  • dtest
  • dumpe
  • dumpi
  • echo
  • einst
  • excep
  • findfunc
  • impmunge
  • member
  • opengl
  • slept
  • talloc
  • tryman

Other TODOs:

  • ARM/ARM64/IA64 support
  • Improve Sample project debugging experiences

@dtarditi
Copy link
Contributor

Please let me know when this is ready for further review.

@LonghronShen
Copy link
Author

I think the current version is ready for review, except for these excluded sample projects.

@bgianfo bgianfo requested a review from dtarditi August 17, 2020 17:58
@bgianfo bgianfo added the enhancement This adds new functionallity to the product label Aug 21, 2020
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_)
Copy link
Contributor

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.

Copy link
Author

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
Copy link
Contributor

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.

Copy link
Author

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...

Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Author

@LonghronShen LonghronShen Sep 2, 2020

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.

Copy link
Contributor

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.

@bgianfo
Copy link
Contributor

bgianfo commented Sep 2, 2020

Can you fix the merge conflicts in .gitignore?

@LonghronShen
Copy link
Author

OK, I'll take it in the next one or two days.

@bgianfo
Copy link
Contributor

bgianfo commented Jan 24, 2021

@LonghronShen can you enable "Allow edits from Maintainer" for this PR?
See: https://github.blog/2016-09-07-improving-collaboration-with-forks/

I have some fixes / additions locally that I would like to include before we merge this PR.

Thanks!

@bgianfo bgianfo added the needs-author-feedback This issue / or pull request requires author feedback before more action can be taken. label Jan 24, 2021
@ghost
Copy link

ghost commented Jan 31, 2021

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.

@bgianfo bgianfo changed the title [WIP] Adding CMake support [WIP] Feature: Adding CMake support Mar 5, 2021
@ghost
Copy link

ghost commented Mar 10, 2021

Any update on this?

@ghost
Copy link

ghost commented Mar 17, 2021

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.

@tostercx
Copy link

Any chance of this getting merged?

@bgianfo
Copy link
Contributor

bgianfo commented Sep 13, 2021

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.

@sylveon
Copy link
Contributor

sylveon commented Sep 13, 2021

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?

@bgianfo
Copy link
Contributor

bgianfo commented Sep 13, 2021

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.
I want it to be feature complete before we merge and use it the one true build system.
CMake can generate NMake as well, so there will be no reason to keep the nmake or sln after this is merged.

@ghost
Copy link

ghost commented Sep 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This adds new functionallity to the product needs-author-feedback This issue / or pull request requires author feedback before more action can be taken. status-no recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants