Detours icon indicating copy to clipboard operation
Detours copied to clipboard

[WIP] Feature: Adding CMake support

Open LonghronShen opened this issue 7 years ago • 22 comments

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.

LonghronShen avatar Dec 10 '18 15:12 LonghronShen

CLA assistant check
All CLA requirements met.

msftclas avatar Dec 10 '18 15:12 msftclas

Thanks for the proposed change. I have some suggestions.

dtarditi avatar Jan 23 '19 21:01 dtarditi

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 avatar Jan 26 '19 14:01 LonghronShen

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.

schlamar avatar Feb 04 '19 10:02 schlamar

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 avatar Feb 04 '19 10:02 LonghronShen

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

dtarditi avatar May 15 '19 22:05 dtarditi

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.

LonghronShen avatar May 16 '19 09:05 LonghronShen

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.

dtarditi avatar May 16 '19 18:05 dtarditi

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

LonghronShen avatar May 16 '19 18:05 LonghronShen

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

dtarditi avatar May 16 '19 20:05 dtarditi

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

LonghronShen avatar May 17 '19 02:05 LonghronShen

Can you fix the merge conflicts in .gitignore?

bgianfo avatar Sep 02 '20 07:09 bgianfo

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

LonghronShen avatar Sep 02 '20 07:09 LonghronShen

@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 avatar Jan 24 '21 10:01 bgianfo

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.

ghost avatar Jan 31 '21 17:01 ghost

Any update on this?

ghost avatar Mar 10 '21 00:03 ghost

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.

ghost avatar Mar 17 '21 05:03 ghost

Any chance of this getting merged?

tostercx avatar Sep 11 '21 18:09 tostercx

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.

bgianfo avatar Sep 13 '21 17:09 bgianfo

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?

sylveon avatar Sep 13 '21 18:09 sylveon

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.

bgianfo avatar Sep 13 '21 18:09 bgianfo

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.

ghost avatar Sep 20 '21 23:09 ghost