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

Global compile options are missing #21

Open
SpriteOvO opened this issue May 30, 2021 · 2 comments
Open

Global compile options are missing #21

SpriteOvO opened this issue May 30, 2021 · 2 comments

Comments

@SpriteOvO
Copy link

SpriteOvO commented May 30, 2021

Simplified example:

top-level CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)

project(FindWDK_IssueTest)

add_compile_options("/MP")

add_subdirectory(Exe)
add_subdirectory(Sys)

Exe CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)

project(FindWDK_IssueTest_Exe)

add_executable(FindWDK_IssueTest_Exe Main.cpp)

Sys CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)

project(FindWDK_IssueTest_Sys)

find_package(WDK REQUIRED)

wdk_add_driver(FindWDK_IssueTest_Sys Main.cpp)

So, I added a compile option /MP to the top-level CMakeLists.txt and want it to work on all subdirectories.
But when I open the generated solution, I see that the compile option only applies to the project Exe and not both.
image
image

Of course, there is a workaround:

top-level CMakeLists.txt:

set(MY_GLOBAL_COMPILE_OPTIONS "/MP")
add_compile_options(${MY_GLOBAL_COMPILE_OPTIONS})

Sys CMakeLists.txt:

wdk_add_driver(FindWDK_IssueTest_Sys Main.cpp)
target_compile_options(FindWDK_IssueTest_Sys PRIVATE ${MY_GLOBAL_COMPILE_OPTIONS})

It works, but obviously not so elegantly.

I personally think this is a bug. So, I was wondering if it is possible for FindWDK to keep global compile options that are safe for driver projects?

Thanks in advance!

@SergiusTheBest
Copy link
Owner

I agree with you. But the question is which compile options are safe for driver projects? Probably it will be wise to add only popular options.

@SpriteOvO
Copy link
Author

SpriteOvO commented Jun 5, 2021

Probably it will be wise to add only popular options.

Yes, my words in the OP were a bit inaccurate, that was just the result I wanted to see, not the solution.

It might be good to use the properties of the solution generated by the VS WDK wizard as a reference. That is, just adding the necessary properties and setting default preprocessor definitions for TARGET.

We can also consider adding a default value to some known properties if they would obviously conflict with the WDK project.

I made this attempt a few days ago, but I got stuck at the beginning.

I tried to fix the Configuration Type and Platform Toolset, but after that I had to change the Windows SDK Version to $(LatestTargetPlatformVersion), because I installed Windows SDK 10.0.18362.0 and 10.0.19041.0, but the WDK only has 10.0.18362.0 installed, so the default value of the Windows SDK Version generated by CMake does not compile for me. And I have tried many ways to do this, but at present it seems impossible to do it from CMake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants