Closed Lucaslah closed 1 year ago
The problem obviously is with the FetchContent_Declare/MakeAvailable
, I'm setting properties on the alias TinyOrm::TinyOrm
inside the TinyOrmConfig.cmake:75
and it normally works when you try to build TinyOrm without these FetchContent_
CMake functions.
I have never used/tried these FetchContent_
functions. The CMake build will have to be fixed to make this work.
So I have played a little with it and the problem is that the TinyOrmTargets.cmake
file is not exported and I don't know why.
Anyway, you can't build with these FetchContent_
functions, it simply doesn't work and have to be fixed.
I think this can be related link or a very similar problem, or this. I don't understand how FetchContent works so I can't tell. It looks like you have to install the target that was FetchContent_MakeAvailable(TinyORM)
.
It looks like this doesn't work out of the box (maybe it works only for the header-only libraries and not for libraries that need to be compiled?):
FetchContent_Declare(TinyOrm
GIT_REPOSITORY https://github.com/silverqx/TinyORM.git
GIT_TAG origin/main
)
FetchContent_MakeAvailable(TinyOrm)
I was successful to build using FetchContent, but I have discovered another bug.
For now, remove find_package
and disable TOM
.
Something like this:
FetchContent_Declare(TinyOrm
GIT_REPOSITORY https://github.com/silverqx/TinyORM.git
GIT_TAG origin/main
)
set(TOM OFF)
FetchContent_MakeAvailable(TinyOrm)
...
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}::Core
TinyOrm::TinyOrm
)
That are good news though 😁, that bug looks simply fixable, I look at it later.
I was successful to build using FetchContent, but I have discovered another bug.
For now, remove
find_package
and disableTOM
.Something like this:
FetchContent_Declare(TinyOrm GIT_REPOSITORY https://github.com/silverqx/TinyORM.git GIT_TAG origin/main ) set(TOM OFF) FetchContent_MakeAvailable(TinyOrm) ... target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core TinyOrm::TinyOrm )
That are good news though grin, that bug looks simply fixable, I look at it later.
This worked for me, thanks very much.
I have already pushed fixes, currently are running CI pipelines, I'm going to make a release, I post an update here afterward.
Alright sounds good.
I have pushed a new release that contains a fix, you can look here what was the fix about.
A few words about the FetchContent
, the FetchContent_Declare()
it's like git clone inside the build folder and then add the cloned folder in a similar way like add_subdirectory(<cloned_folder>)
does and the FetchContent_MakeAvailable(<package>)
internally calls the find_package(<package>)
or if you define OVERRIDE_FIND_PACKAGE
then you don't have to call the the FetchContent_MakeAvailable()
and you must call the find_package(<package> x.y.z CONFIG REQUIRED)
manually.
An advantage of the OVERRIDE_FIND_PACKAGE
is that you can call it much later and you can insert configurations between.
So you can include the TinyORM
like this:
set(FETCHCONTENT_QUIET OFF)
include(FetchContent)
FetchContent_Declare(TinyOrm
GIT_REPOSITORY https://github.com/silverqx/TinyORM.git
GIT_TAG origin/main
)
# Here you can configure TinyORM CMake options
set(MYSQL_PING ON)
set(TOM_EXAMPLE ON)
FetchContent_MakeAvailable(TinyOrm)
...
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}::Core
TinyOrm::TinyOrm
)
or like this:
set(FETCHCONTENT_QUIET OFF)
include(FetchContent)
FetchContent_Declare(TinyOrm
GIT_REPOSITORY https://github.com/silverqx/TinyORM.git
GIT_TAG origin/main
OVERRIDE_FIND_PACKAGE
)
# Here you can configure TinyORM CMake options
set(MYSQL_PING ON)
set(TOM_EXAMPLE ON)
...
find_package(TinyOrm 0.16.0 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}::Core
TinyOrm::TinyOrm
)
Maybe it helps someone in the future 😎
I cannot get this to work with cmake, I get the following error:
CMake Version: 3.22 In my
CMakeLists.txt
I'm not sure if I'm missing something.