0

I am currently working on a project which requires SQL database. I want to make project platform independent so i am writing CMakeLists.txt but unfortunately its not working with linux currrently I have this part in CmakeLists.txt

find_package(ODBC)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}_component ${ODBC_LIBRARIES} CML)

I know that I have to put ifelse for platform so i am thinking in this direction

if (WIN32)
    find_package(ODBC)
    TARGET_LINK_LIBRARIES(${PROJECT_NAME}_component ${ODBC_LIBRARIES} CML)
endif (WIN32)


if (UNIX)
   ## dont know what to write here ?? 
endif (UNIX)

Ps. I am very beginner in CMake writing so I would really helpful if someone can guide me .

1 Answers1

2

You might want to use FindODBC:

Find an Open Database Connectivity (ODBC) include directory and library.

On Windows, when building with Visual Studio, this module assumes the ODBC library is provided by the available Windows SDK.

On Unix, this module allows to search for ODBC library provided by unixODBC or iODBC implementations of ODBC API.

Paul Evans
  • 27,315
  • 3
  • 37
  • 54