CMake build fails if the mpg123 is added with add_subdirectory() to existing...
Brought to you by:
sobukus
CMake build fails if the mpg123 is added with add_subdirectory()
to existing CMake project. For example, here is how it's done for Conan package manager's CMake project wrapper:
cmake_minimum_required(VERSION 3.4)
project(cmake_wrapper)
include(conanbuildinfo.cmake)
conan_basic_setup()
add_subdirectory(source_subfolder/ports/cmake)
In this case the source_subfolder
contains mpg123 repository and for such CMakeLists.txt
the
cmake -G "Visual Studio 15 2017 Win64"
will produce the error:
CMake Error at source_subfolder/ports/cmake/cmake/read_api_version.cmake:3 (file):
file failed to open for reading (No such file or directory):
C:/J/w/prod/BuildSingleReference@5/.conan/data/mpg123/1.29.3/_/_/build/fe37d0493f91b5e4c13e7de0e5f46d3174dff5b9/../../configure.ac
The root cause is that the CMAKE_SOURCE_DIR
used in ports/cmake/cmake/read_api_version.cmake
points to the parent CMake project folder instead of the mpg123's CMake project folder. In the past the PROJECT_SOURCE_DIR
was used instead.
Broken with the commit:
Revision 4887 - (view) (download) (annotate) - [select for diffs]
Modified Thu May 6 11:10:43 2021 UTC (10 months, 1 week ago) by thor
File length: 723 byte(s)
Diff to previous 4717
ports/cmake: also read project version (only the 1.2.3 part)
CMake's regexes suck. And I suck and writing them. So only the
version without any hypothetical suffix.
Locally I've tried the
CMAKE_CURRENT_SOURCE_DIR
instead ofCMAKE_SOURCE_DIR
and it fixed the issue.So you recommend this variable instead of the project one?
Yes, the
CMAKE_CURRENT_SOURCE_DIR
looks like a more correct change.OK, I hope current trunk is fine. Thanks.