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

If used as child CMake directory, parent CXXFLAGS_DEBUG etc are forcibly cleared in parent CMakeCache.txt on MacOS (and probably any platform but MSVC) #54

Closed
bradgrantham opened this issue Mar 18, 2021 · 0 comments

Comments

@bradgrantham
Copy link
Contributor

MiniFB is great, and I'm happy to have it! I'm using minifb as a submodule in my project using add_subdirectory() in my CMakeLists.txt.

I think that the lines in CMakeLists.txt in f66e92c between 121 and 135 of the form set(CMAKE_... "" CACHE STRING "" FORCE) are forcing the system CMAKE_... variables to be overwritten in CMakeCache.txt. E.g. A line CMAKE_CXX_FLAGS_DEBUG:STRING= is emitted into my CMakeCache.txt. These variables are therefore overwritten for my project, and, if I understand CMake correctly, for every other subdirectory which doesn't explicitly set them.

But I expect CMAKE_CXX_FLAGS_DEBUG:STRING=-g. If I compile my project with -DCMAKE_BUILD_TYPE=Debug, none of my project code is compiled debug, and I have no symbols in my executable and can't do any symbolic debugging with lldb. Additionally my environment CXX_FLAGS is ignored (in which I have "-Wall")

If I remove CACHE STRING "" FORCE from those lines, my code compiles Debug just fine (and my environment CXX_FLAGS are honored, which had been missing up to this point) and MiniFB still clears the system compile flags and gets its custom build flags specified at 139 and 140.

Is it possible you don't want to set those variables in the cache at all?

bradgrantham added a commit to bradgrantham/minifb that referenced this issue Mar 18, 2021
Don't set CMAKE_..._FLAGS... in the cache
Darky-Lucera added a commit that referenced this issue Apr 30, 2021
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

1 participant