-
Notifications
You must be signed in to change notification settings - Fork 277
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
(Almost) complete CMake support added #97
Conversation
The XMMS plugin support is of very low priority. PPC support is also low priority. I try to keep it working and if it gets broken I expect someone with a PPC machine to help fix it.
I have looked at that, and unfortunately it looks like a huge task. Not sure how the tests are currently built and run on Windows with the VS project. |
built: VS builds the following .exe files (along with flac.exe and metaflac.exe, of course): run: they don't, AFAICS |
Well, the scripts in /test folder still can be used on Unix since CMake builds all the binaries which those scripts reference |
Just ran (from the .travis.yaml file from libsndfile):
and got:
|
@erikd You need either to add -DWITH_OGG=OFF flag or to build xiph/ogg#40 and install it somewhere and then add -DOGG_DIR= (-DOGG_DIR is needed only if OGG doesn't get into standard installation paths on UNIX) BTW, -Wall -Wextra are enabled by default, as well as the others from configure.ac |
@krokoziabla I have the ogg development libraries installed in the standard location. The Cmake build systems should be able to find them (like it does for libsndfile). The |
Ok, now it can find the Ogg libraries, but the full test suite is not being run. The full test suite takes about 30 minutes. |
Oh, sorry, I should have used another temporary branch so that you didn't see my temporary commits. I needed some time to make my fix stable on all the platforms I have. Now it is ready
Not sure I get your point. The other tests still can be run but for that one needs to run something like this: |
Ok, let me know when you have this sorted. |
Do you mean you suggest converting tests to C/C++ or what? FindOGG.cmake seems to work well now, I don't have anything else to do with it. |
I would not recommend that. Is there no other way to get the full test suite running? |
Done. I've made those scripts run by |
@krokoziabla Why so many |
At least 31 CMakeLists.txt flies out of 43 contain a target. Most of the rest contain some install() and add_test() commands. In general my intention was to avoid creating a GOD-like CMakeLists.txt |
Then you have another problem - too many targets. Visual Studio will not be happy to handle this. |
Also, for Windows linking STATIC libraries is OK, what about other OSes? At least Linux requires |
One more thing - FLAC uses math functions, so under Unix math library must be linked ( |
I guess you're speaking about two different things at one time - too many CMakeLists.txt vs. too many targets. I believe the number of targets cannot be reduced.
Too abstract... You can try it yourself. I didn't experience any problems with VS while building this
If you look into the CMakeLists.txt for libFLAC and libFLAC++ you'll see that there're two variants of libraries built - static and shared
... and it is |
Sorry, i found it. |
And both are linked to the same STATIC utf8 library. |
No. I mean if you will remove bunch of useless STATIC libraries you will remove banch of useless CMake scripts. Simpler is better. |
No. Only executables link to utf8, not shared libFLAC or libFLAC++
The structure of targets/libraries was inherited from exirting automake/*.vcxproj files. I think it is not my business to change this. Probably the product owner will reorganase the repository later if he or she finds it useful. |
I se now. Then OK. |
No ABI version. This is critical for UNIX. set_target_properties(FLAC PROPERTIES
VERSION 8.3.11
SOVERSION 8
) |
Why is it 8.3.11? I cannot find it anywhere in the repo. |
There also seems to be a problem running the tests one machines where the Ogg libs are not installed. Specifically it seems to hang at:
I suspect this is an issue with Another issue seems to be the test output. With the autotool test output the output is like:
whereas the CMake build output is:
Would be nice to have the CMake output the same as the autotool output. |
Are you sure you compiled a release build? If you add -DCMAKE_BUILD_TYPE=Release CMake will pass NDEBUG to gcc and this output will be suppressed. It works in my setup |
I've checked now that if there is no OGG on my Mac then I don't see As to those newlines - fixed. |
Is it possible to make the release build the default? That is the way it is with autotools. |
Done |
Looking good. Will merge this in the morning. |
Enable components search in package config mode
@cristianadam Thanks. Fixed |
@evpobr Amen about Cmake not needing a shit ton of CmakeLists.txt files laying around. I personally just have a /Projects folder that contains a single CmakeLists.txt, and the source is in ../libX/ then I use git's submodules to incorporate various libraries together into a bigger project. Quick question, is there a way to have the user set the library type (in a shared/static sense, not debug/release)? add_library requires either STATIC or SHARED and I'm unsure if there's an official way to do that or not. |
@MarcusJohnson91 you can use set BUILD_SHARED_LIBS variable for that https://cmake.org/cmake/help/latest/command/add_library.html |
As mentioned in #100 (comment) it would be nice to have something in the README explaining how to use CMake with Visual Studio. |
Done. But I apologise for my English. It's not very fluent. Probably you'll want to edit this part afterwards |
@krokoziabla, I see OGG in documentation. It is not abbreviation, the correct name is Ogg. Just to be clear. |
Just saw this, I think it is a must (at least for me) to have a cmake option to change MSVC runtime settings without manually patching CMakeLists.txt. https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake |
@Chocobo1 If I'm not mistaken you can regulate that by passing /Mx flags to CMake in CMAKE_C_FLAGS_RELEASE or CMAKE_C_FLAGS_DEBUG variables. Does it work for you? |
if (ENABLE_STATIC_RUNTIME)
if (MSVC)
foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
)
if (${flag_var} MATCHES "/MD")
string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif ()
endforeach (flag_var)
endif (MSVC)
endif() CMake 3.15 will have CMAKE_MSVC_RUNTIME_LIBRARY option to handle this. |
Yes, but I'm wishing for an explicit cmake configure option, or even better the snippet evpobr suggested.
Glad to know they finally are going to put this nuisance to an end. |
One can use a toolchain with CMake version 3.11+ to change the msvc runtime library without touching the CMake code. Actually one shouldn't change CMAKE_C|XX_FLAGS in CMake code directly, you should use a toolchain. See how it can be done here: https://cristianadam.eu/20190223/modifying-the-default-cmake-build-types/ |
Will someone please let me know when this is ready to be merged? |
Well, I don't have plans to add anything to it. I think it is ready to use in the sense that it provides basic functionality: it can build, test and install the lib. Forsure it always can be improved and extra features can be added but then we will never merge this PR if all of them go here. I would propose to merge it now and let further extentions of functionality be proposed by other PRs, it there are any |
@cristianadam @Chocobo1 @evpobr Anything further needed? |
No. |
Thank you all! This has been merged to master and pushed to https://git.xiph.org/flac.git . It should be mirrored here within a couple of hours. |
I examined the contents of configure.ac and Makefile.am's and *.vcxproj's and wrote a suite of CMakeLists.txt according to them. Everybody is welcome to try it out and suggest any comments or ideas on how to improve it.
Tested on Windows (MSVC, cygwin+gcc), on Mac (Xcode+clang, make+clang), on Linux (Ubuntu, Arch, Gentoo, make or ninja + clang or gcc), FreeBSD (clang+make)
Things to consider:
Fixes #43