Poco 1.9.0: Data to SQL

~ 2 minute read.

This is a very spe­cif­ic prob­lem to which I put up the so­lu­tion for those of you googling for it.

To save you some time: the “Da­ta” names­pace in Poco has been re­named to “SQL” in POCO 1.9.1. This can take shape in the fol­low­ing er­rors, in case you search for them:

CMake Find Error

When com­pil­ing your ex­ist­ing project, you may run in­to the fol­low­ing er­ror af­ter com­pil­ing POCO:

> cmake .. -DCMAKE_INSTALL_PREFIX=C:\local -A x64
CMake Error at [...]/cmake/PocoConfig.cmake:29 (find_package):
Could not find a package configuration file provided by "PocoData" with any
of the following names:

   PocoDataConfig.cmake
   pocodata-config.cmake

Add the installation prefix of "PocoData" to CMAKE_PREFIX_PATH or set
"PocoData_DIR" to a directory containing one of the above files.  If
"PocoData" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:28 (find_package)


-- Configuring incomplete, errors occurred!
See also "[...]/CMakeFiles/CMakeOutput.log".

So­lu­tion

Make sure to com­pile POCO with -DPOCO_ENABLE_SQL_<DB>=ON, where <DB> is one of the data­bases you’d like to use, e.g. SQLITE or MYSQL.

You then need to make sure to change the name of the com­po­nent in the find_package call:

+ find_package(POCO REQUIRED Data DataSQLite)
- find_package(POCO REQUIRED SQL SQLSQLite)

Missing CMake Target

You will get this as a fol­lowup:

CMake Error at src/CMakeLists.txt:3 (add_library):
  Target "[...]" links to target "Poco::DataSQLite" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

So­lu­tion

Change all oc­cu­rances of Poco::DataSQLite cmake tar­get to Poco::SQLSQLite in your target_link_library calls ana­log to the find_package call.

Compile Errors

The fol­lowup er­ror is a com­pile er­ror:

[...]: error C2039: 'Data': is not a member of 'Poco' [...]

Hence, now you need to refac­tor all us­es of the Data names­pace to SQL.

Hope this saved you a minute!

Writ­ten in 30 min­utes.