-
Notifications
You must be signed in to change notification settings - Fork 19
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 refactoring: add CMakeLists.txt and function add_max_target() #8
base: main
Are you sure you want to change the base?
Conversation
Hi @Mc-Zen ! Would you be able to reduce the amount of duplication between script/add_max_target.cmake and script/max-pretarget.cmake without breaking backward compatibility of the pretarget script? |
Hi, I did try that but it is nothing less then trivial and I'm not sure 100% backwards compatibility can be guaranteed. The file script/max-pretarget.cmake mostly sets variables which makes it hard to use functions as they are scoped. Using macros solves this issue mainly but there needs to be a common CMake file containing these functions. This file (let's say The issue with that is that
For However it is not clear how Another option is to |
- interface-link max-sdk-base to c74 libs so linking to it immediately transfers these libs. Therefore, manual linking - add generator expressions to include directories in order to enable min-api to export a package
Oh and by the way: i have some questions
|
…retarget.cmake (need to swap add_subdirectories for min-api and min-lib in min-devkit)
Actually, I found a solution for the issue above with including included CMake files and most of script/max-pretarget.cmake can be moved to macros which also can be used from the new function. However: for one step, it would be necessary to swap the I pushed the draft. It may need some testing for other projects than the ones in the min-devkit but there is seems to work well now! |
@Mc-Zen This is looking good so far!
In that case, I would like to wait on approving/merging/etc. this PR before seeing proposed changes to other repositories as well. |
- add max-sdk-base-header target to use only includes but not msp/jit/max libs (used for unit tests) - change to some macros
- rename add_max_target -> c74_add_max_target - set linker flags for apple in c74_add_max_target as CMAKE_MODULE_LINKER_FLAGS does not work for some reasons
Hi @Mc-Zen, Just checking in on this -- thanks for patience. Are the other PRs on min-api and min-devkit also ready? I didn't want to add any comments until all repositories' PRs were ready. |
Hi @isabelgk Yes, they are ready - at least I thought so. Last week I tried to set up some extended unit testing for a max external and had some problems with a more complicated setup. A part of it is a typo made by me in the PR and another is a global CMAKE parameter that is set but here an elegant solution exists. I will add these two fixes very soon. The other issue is a bit harder. Whenever an external uses functions from MaxApi, MaxAudioApi or Jitter (and most would), a test fails to compile because of missing linkage to those libraries. This was already the case before I made changes to the build system. We can add the missing library targets as we do for the external itself. However, all of these libraries have a dynamic library component which needs to be loaded at runtime. I believe Max 8 usually takes care of this - and for Windows the required dll files are found in the Max 8 installation. But of course the test runner will not find them. Do you have a suggestion for that? It would be great to be able to write proper unit tests for max externals. What does work is copying the dlls into the But the latter issue does not need to be solved now, just wanted to throw it in for consideration. |
…ep -> making it only be applied to the target, not globally for all following targets The lines https://github.com/Cycling74/max-sdk-base/blob/9aafaeb39536ecddd9e4d839d96326e44ca28bab/script/macros.cmake#L8-L25 (which are taken from max-pretarget.cmake) set some global parameters which are also applied to any other following target thus preventing linking to some libraries. The intend is solely to activate the MT/MTd flag for VS (I checked for all default flags and this is the only change). An elegant solution exists by instead calling ``` set_target_properties(${target} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") ``` applying it only to the given target.
Done. Everything ready so far |
Thanks for all the work @Mc-Zen ! I'll need a bit of time to review the changes thoroughly before being able to let you know how we'll proceed.
I don't have a suggestion about this at the moment, but since it sounds like it is unrelated to your changeset, perhaps a separate issue thread would be appropriate and we can take a peek later on. |
Hi @Mc-Zen , As a first test of these changes, I used the percolate package which just uses the Without changing any CMake files in the existing project, I get the following errors when configuring:
|
Hi @isabelgk , Adding *this was necessary in order to reduce the code duplications |
Thanks for the explanation! Unfortunately, this requirement (of needing |
Mmh alright, I understand that. It would have been nice however to review the changes for max-sdk-base before I invested the work into min-api and min-devkit. There is certainly a way to make it work without the CMakeLists.txt but this would be a very tedious job because the built system was designed in a way that many hardcoded, relative paths go to a lot of places which does not scale too well with the multirepo/submodules approach. The main issue is related to things like getting max-linker-flags.txt from other directories. With functions, targets etc. this is possible but the existing scripts rely on the calling/including file to be at exactly the right level of nesting relative to the file (e.g. max-linker-flags.txt) |
I agree that such a refactoring could be quite time-intensive and require a lot of testing to ensure we don't break folks' current workflows (including internal ones within Cycling '74), though the requirement of not breaking older workflows at the moment is a priority. Also you're right that it would have been better to have had testing on these changes before having you invest time into min-api and min-devkit. I apologize for that. |
Well, it is how it is and of course not breaking compatibility is important. I even looked into the thing again but I'm afraid the issue sits quite deep :/ Anyhow, I wish you a nice weekend! |
Changes by adding a
CMakeLists.txt
are:CMakeLists.txt
file and provides an interface library so that when a target is linked against it, the include paths for c74support, jit-includes, max-includes and msp-includes are inherited.C74_Libraries
) for possible organisation in an IDE.Changes in comparison to the scripts that are currently used:
add_max_target()
is used to create a library target (i.e. an external) with the necessary configuration that is otherwise done by the pre- and post-scripts. This function will be called by a new functionadd_min_target()
from the min-api. AMODULE
library is already created here.../../../externals
(as done in the script) because this only works when used in the exact same setup as in the min-devkit. Instead, a corresponding function in the min-devkit will then do this.Note:
jit, max and msp could also have their own interface libraries but I'm not sure if it would be useful to include just some instead of all of them.
Outlook:
A
CMakeLists.txt
file that is located in the min-devkits projects folder could later look like this: