-
Notifications
You must be signed in to change notification settings - Fork 197
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
cmake: Allow out-of-tree builds #201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
|
||
CMakeCache.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these removed from .gitignore
? people may still default to in-tree builds where this is useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any value in in-tree builds but re-added that.
Do note that whatever you're changing has to preserve things working as before on Windows / OS X. Not sure about Meson, I dislike CMake as much as the next guy, but it is a standard many are familiar with. |
As I understand it, CMake is only used on Linux so it should be the same (the C++ code changes should still be compatible). Eventually, it would be nice to use CMake (or Meson) to generate VS and XCode boilerplate, and there we should follow the best practices for each individual platform, not necessarily the current behaviour.
I did not realize CMake supports VS backend too, so there is a less of a pressure to switch to Meson. |
Yes, but like you said I'd like to keep the door open to eventually migrate over to using CMake everywhere. |
elseif (WIN32) | ||
foreach(locale ${locales}) | ||
install( | ||
FILES "TS/translations/${locale}/ts.mo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what this is going to do. Even if we ever had an "installer creation" on Windows, there's no need to be copying locale files, these files are tiny and the right one is automatically picked up by treesheets anyway. Better to just assume the files will get copied wholesale, and not introduce things which may break in interesting ways in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for os x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will copy the locales to the correct path according to the platform, as described by the wxWidgets docs.
I also want to make msgfmt call part of the build as .mo
files are not portable. Possibly, that can cause issues on systems e.g. with different endianness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That just shows where they would reside relative to the executable on win/osx. In both cases, they'd be in an installer or app package along with all the other standard files, and TreeSheets already knows how to access those, so there is no need for an install action on these platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not very familiar with those platforms, but I would expect CMake to generate installers/bundles for those platforms (e.g. https://cmake.org/cmake/help/latest/cpack_gen/nsis.html for Windows). So if we want to use CMake on those platforms, we will also want to specify the platform-specific paths here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we ever do so thru CMake, we will do the entire data dir, not just individual locale files. Please remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the issue is that the directory tries have different layout from the one used in TS/
on both Windows and Mac. And we also do not want to install junk like the bat files. So we will need to install individual files anyway.
But removed, for now, since I do not have the option to test those platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have implemented the FHS locale path and tested that the Italian translation works when installed there. There are still some questions to resolve.
CMakeLists.txt
Outdated
@@ -24,11 +25,13 @@ cmake_minimum_required(VERSION 3.1) | |||
|
|||
project(treesheets) | |||
|
|||
include(GNUInstallDirs) | |||
|
|||
set(TREESHEETS_RELOCATABLE_INSTALLATION OFF CACHE BOOL "Enable to look for data relative to the path treesheets was run from, instead of hardcoding paths from CMAKE_INSTALL_PREFIX") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need this option. The reason I introduced it is that I wanted to prevent relocatable builds from loading the locales from install prefix (e.g. when user has an older version installed on their system and fresh one installed into a testing directory).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have absolutely no knowledge of install procedures and locales, so can't help with this.
Maybe @probonopd can comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the option just serves to toggle between the FHS-compatible layout and the layout used on Apple and Windows.
@@ -21,6 +21,9 @@ struct MyApp : wxApp { | |||
#ifdef __WXGTK__ | |||
locale.AddCatalogLookupPathPrefix(L"/usr"); | |||
locale.AddCatalogLookupPathPrefix(L"/usr/local"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the FHS paths are already hardcoded (even though they will not work due to missing /locale
subdirectory).
a6b0ad2
to
82872e2
Compare
Now it installs all files to their preferred directories on Linux, while (unless I missed something) keeping the old layout on Windows and Mac: Directory tree
|
3d9645c
to
4b834f0
Compare
ok lgtm, let me know when you think its ready to merge. |
It should be good to merge now (once CI finishes). |
Hmm, looks like we need to bump MACOSX_DEPLOYMENT_TARGET:
|
This is a best practice, allowing easier development (not having to worry about cleaning the source directory).
We still need to keep MyApp::AddTranslation for cases when the app is built with something other than CMake, and on other platforms than Linux. We are also adding a TREESHEETS_RELOCATABLE_INSTALLATION CMake configuration flag that allows installing to the old relocatable location even on Linux. Finally, we only install the necessary `*.mo` files, not the `*.po` files or `*.bat` helper scripts.
This is needed to make Linux distributions happy. Had to bump minimum macOS version to Catalina since std::filesystem::path is not supported on older versions than 10.15. macOS 10.14 (Mojave) is unsupported since October 2021.
Thanks for your work on this! |
- Switch to unstable, using tagged releases is discouraged: aardappel/treesheets#150 (comment) - Also add updateScript to that effect. - CMake is now preferred on Linux, and it installs files to proper locations: aardappel/treesheets#201 - CMake does not set version correctly so we need to do it ourselves. - Format the expression.
- Switch to unstable, using tagged releases is discouraged: aardappel/treesheets#150 (comment) - Also add updateScript to that effect. - CMake is now preferred on Linux, and it installs files to proper locations: aardappel/treesheets#201 - CMake does not set version correctly so we need to do it ourselves. - Format the expression.
Software on most Linux systems is expected to follow [Filesystem Hierarchy Standard](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html. Let’s update the CMake build to support it so that each Linux distro does not have to do this on its own. On Windows, we can still have it relocatable.
Fixes: #133
Eventually, we might want to switch to Meson instead of CMake, which might allow us to get rid of the Visual Studio boilerplate since it can generate it.