Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

Add CMake package configuration (feature #243) #245

Merged
merged 1 commit into from
Mar 21, 2017
Merged

Add CMake package configuration (feature #243) #245

merged 1 commit into from
Mar 21, 2017

Conversation

mloskot
Copy link
Contributor

@mloskot mloskot commented Mar 19, 2017

  • Exports nanodbc target
  • Generates nanodbc-config.cmake
  • Make project importable from both, install and build directory

Add examples/client project with example of nanodbc target importing.


Addresses feature request #243

TODO

  • Bump CMake requirement to 3.0.0 or later (3d8e427)
  • Export nanodbc target
  • Make project importable from the install directory
  • Make project importable from the build directory
  • Add example of client using imported nanodbc target.
  • Add CI build running install target (AppVeyor only)
  • Building the new client relying on find_package(nanodbc) as part of CI build

AppVeyor build 1.0.435 shows the nanodbc package config file in action:

  • Running install:
[  5%] Built target nanodbc
...
[100%] Built target example_table_schema
Install the project...
-- Install configuration: "Release"
-- Installing: C:/Program Files (x86)/nanodbc/lib/nanodbc.lib
-- Installing: C:/Program Files (x86)/nanodbc/include/nanodbc.h
-- Installing: C:/Program Files (x86)/nanodbc/cmake/nanodbc-config.cmake
-- Installing: C:/Program Files (x86)/nanodbc/cmake/nanodbc-config-release.cmake
  • Building examples/client based on nanodbc package configuration and find_package(nanodbc) call:
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- nanodbc package found - 1
-- nanodbc package directory - C:/Program Files (x86)/nanodbc/cmake
-- Configuring done
-- Generating done
-- Build files have been written to: C:/projects/nanodbc/examples/client
Scanning dependencies of target nanodbc_client
[ 50%] Building CXX object CMakeFiles/nanodbc_client.dir/nanodbc_client.cpp.obj
nanodbc_client.cpp
C:\projects\nanodbc\examples\client\nanodbc_client.cpp(13): warning C4101: 'e': unreferenced local variable
[100%] Linking CXX executable nanodbc_client.exe
[100%] Built target nanodbc_client

/cc @lexicalunit

@mloskot mloskot self-assigned this Mar 19, 2017
@lexicalunit
Copy link
Owner

lexicalunit commented Mar 20, 2017

There's a small issue with respect to cmake 3.0 and Apple's clang. According cmake to documentation the compiler id is now AppleClang. Below is a diff to fix a build issue this causes. We just need to replace STREQUAL with MATCHES.

I also noticed some unicode characters snuck into some documentation so I fixed that in the diff below. We could do that in a separate PR or roll it into this one.

Other than that one small issue this looks great! 🎉

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9547b4c..52d3524 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,7 @@ option(NANODBC_ENABLE_LIBCXX "Use libc++ if available." ON)
 ########################################
 ## require and enable C++0x/11/14
 ########################################
-if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
   include(CheckCXXCompilerFlag)
   CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
diff --git a/src/nanodbc.h b/src/nanodbc.h
index 4449fea..79cb1c4 100644
--- a/src/nanodbc.h
+++ b/src/nanodbc.h
@@ -1358,7 +1358,7 @@ public:
     /// \brief Returns a identifying integer value representing the SQL type of this column by name.
     int column_datatype(const string_type& column_name) const;

-    /// \brief Returns data source<96>dependent data type name of this column.
+    /// \brief Returns data source dependent data type name of this column.
     ///
     /// The function calls SQLCoLAttribute with the field attribute SQL_DESC_TYPE_NAME to
     /// obtain the data type name.
@@ -1367,7 +1367,7 @@ public:
     /// this function cost is an extra ODBC API call.
     string_type column_datatype_name(short column) const;

-    /// \brief Returns data source<96>dependent data type name of this column by name.
+    /// \brief Returns data source dependent data type name of this column by name.
     ///
     /// The function calls SQLCoLAttribute with the field attribute SQL_DESC_TYPE_NAME to
     /// obtain the data type name.

@mloskot
Copy link
Contributor Author

mloskot commented Mar 21, 2017

@lexicalunit Your fixes are in, d7075e9 and 186529b. Thanks

- Exports nanodbc target
- Generates nanodbc-config.cmake
- Make project importable from both, install and build directory

Add examples/client project with example of nanodbc target importing.
@mloskot mloskot merged commit 488e600 into lexicalunit:master Mar 21, 2017
@mloskot mloskot deleted the ml/config.cmake branch March 21, 2017 21:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants