I am using CMake to define my projects. My goal is to have platform-specific files easily accessible for editing, searching, browsing, and source control with across all platforms.
I currently have platform-specific files separated in the cmake description. My CMakeLists.txt file looks something like the following:
Foo.hpp
${platform_directory}/Foo.cpp
Then on disk I have something like this:
Foo.hpp
win
`- Foo.cpp
osx
`- Foo.cpp
Which in the generated project file looks like:
Foo.hpp
Foo.cpp (platform-specific version)
This is perfect for the compiler, but it means that developers lack IDE tooling for non-native platform-specific files.
What I am looking for is something like this (in Xcode):
Foo.hpp
Foo.cpp (OS X version)
win
`- Foo.cpp (file type set to plain text)
Or in Visual Studio:
Foo.hpp
Foo.cpp (Windows version)
osx
`- Foo.cpp (build action set to none)
Any ideas on how something like this can be setup CMake?
One way would be to add a custom target with no build rules, specifically to hold the files which aren’t part of the given platform’s build; e.g.
Another option (perhaps closer to what you want, but a bit more “hacky”) is to add all the files to the target, but mark the ones not required for the build as
HEADER_FILE_ONLY: