cmake: Add extra lib and include paths when building on MacOS

When compiling with cmake on MacOS, search for the SQLite library and
include files in some other irectories before falling back to the standard
paths.
Maybe this fixed the issue at
https://github.com/rp-/sqlitebrowser/issues/42
This commit is contained in:
Martin Kleusberg
2014-05-09 19:26:21 +02:00
parent 0def8fd674
commit 954cc2f689

View File

@@ -138,7 +138,15 @@ if(WIN32)
ENDIF( MINGW )
endif(WIN32)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ANTLR_DIR} ${QHEXEDIT_DIR} ${QCUSTOMPLOT_DIR} src)
# add extra library path for MacOS
if(APPLE)
find_library(LIBSQLITE sqlite3 HINTS /usr/local/lib /usr/local/opt/sqlite/lib)
set(ADDITIONAL_INCLUDE_PATHS /usr/local/include /usr/local/opt/sqlite/include)
else(APPLE)
find_library(LIBSQLITE sqlite3)
endif(APPLE)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ANTLR_DIR} ${QHEXEDIT_DIR} ${QCUSTOMPLOT_DIR} ${ADDITIONAL_INCLUDE_PATHS} src)
add_executable(${PROJECT_NAME} ${SQLB_HDR} ${SQLB_SRC} ${SQLB_FORM_HDR} ${SQLB_MOC} ${SQLB_RESOURCES_RCC})
@@ -150,7 +158,7 @@ add_dependencies(${PROJECT_NAME} antlr qhexedit qcustomplot)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/${ANTLR_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${QHEXEDIT_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${QCUSTOMPLOT_DIR})
target_link_libraries(${PROJECT_NAME} antlr qhexedit qcustomplot ${QT_LIBRARIES} ${WIN32_STATIC_LINK} sqlite3 ${ADDITIONAL_LIBS})
target_link_libraries(${PROJECT_NAME} antlr qhexedit qcustomplot ${QT_LIBRARIES} ${WIN32_STATIC_LINK} ${LIBSQLITE} ${ADDITIONAL_LIBS})
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin