-
Notifications
You must be signed in to change notification settings - Fork 63
Added a config to export the library as a cmake target #66
Conversation
Sorry for being late, 😸 |
Thanks for the update. I appreciate the effort you put into this. However, this now has hundreds of lines of code for the equivalent of Your initial statement was:
I have no relevant knowledge of vcpkg and my cmake skills are rather limited. I cannot imagine that anything like this is necessary to make them work together. Please do more research. There has to be a better way. Thanks! |
Sorry, that was me being lazy, I copied a whole module where I needed just a single function, removed that and replaced that with a small command.
I can't link against the connector since no targets were exported corresponding to it. So unless the libraries and headers exist in the system path, it would be a hassle to use it. That is what I think, though I could be definitely wrong. |
Put a check for the TAG variable if not set, I am out of ideas on how to tackle this if there is not .git or |
Thanks! @Leon0402 and @GCarneiroA My cmake foo is insufficient to figure out if this would conflict with #65? |
|
||
install( | ||
FILES | ||
"../cmake/sqlpp11-connector-mysqlConfig.cmake" |
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 did you copy the config file in the binary directory in line 17, if you now use the path to the cmake directory directly?
Also instead of using "../cmake", you could also use "${PROJECT_SOURCE_DIR}/cmake/", which I personally like more. But that might be preference.
"${CMAKE_CURRENT_BINARY_DIR}/cmake/sqlpp11-connector-mysqlConfig.cmake" | ||
COPYONLY) | ||
|
||
set(ConfigPackageLocation lib/cmake/sqlpp11-connector-mysql) |
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.
To be compatible with all major distributions / OS, you should rather not hardcode the destinations path here. Instead cmake can figure out the correct directory:
include(GNUInstallDirs)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/sqlpp11-connector-mysql)
bind_result.cpp | ||
detail/connection_handle.cpp) | ||
add_library(sqlpp-mysql connection.cpp prepared_statement.cpp char_result.cpp | ||
bind_result.cpp detail/connection_handle.cpp) | ||
|
||
install(TARGETS sqlpp-mysql DESTINATION lib) |
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 can be removed I guess
VERSION ${TAG} | ||
COMPATIBILITY AnyNewerVersion) | ||
|
||
export( |
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 shouldn't be necessary, it is done by install(EXPORT ...) in line 23
FILES | ||
"../cmake/sqlpp11-connector-mysqlConfig.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/sqlpp11-connector-mysqlConfigVersion.cmake" | ||
DESTINATION ${ConfigPackageLocation}) |
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.
Actually nothing here, but I can't comment on code you haven't changed (Why Github?). In the top level cmake file there is the installation command for the header files. You might wanna move them in here, to have everything installation related in one place
@@ -0,0 +1,6 @@ | |||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") |
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.
Seems to be not needed
It should be alright as far as I can see. But @GCarneiroA made some good changes over there, which this patch could benefit from. He added target specific commands like
The INSTALL_INTERFACE part can be removed, when using As far as I can see the @GCarneiroA took this into account in his patch, although the INSTALL_INTERFACE part isn't correct I think. So I think it might be better to merge the other PR first and then rebase here. But I'm not sure if @GCarneiroA is still working at the other PR, it seems stale. |
The mysql-connector now lives in the sqlpp11 repo. Closing this before archiving. Please re-open in sqlpp11, if this is still relevant. Thanks! |
This exports the library as a cmake package with
sqlpp11::sqlpp-mysql
target. Don't know if it is necessary or not, but I needed it to link against my program when installed this library from vcpkg. I have kept it under thesqlpp11
namespace, since package name is pretty long.