diff --git a/CMakeLists.txt b/CMakeLists.txt index 11f81aae..4cf8f99a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,10 @@ if (NOT BUILD_OPTION_DOC_ONLY) #--------------------------- if (DEFINED ENV{LIBRDKAFKA_INCLUDE_DIR}) set(LIBRDKAFKA_INCLUDE_DIR $ENV{LIBRDKAFKA_INCLUDE_DIR}) - else () + elseif (NOT DEFINED LIBRDKAFKA_INCLUDE_DIR) find_file(LIBRDKAFKA_HEADER NAMES rdkafka.h - HINTS /usr/include/librdkafka /usr/local/include/librdkafka /opt/homebrew/include/librdkafka) + HINTS /usr/include/librdkafka /usr/local/include/librdkafka /opt/homebrew/include/librdkafka /home/linuxbrew/.linuxbrew/include/librdkafka) cmake_path(GET LIBRDKAFKA_HEADER PARENT_PATH LIBRDKAFKA_INCLUDE_DIR) cmake_path(GET LIBRDKAFKA_INCLUDE_DIR PARENT_PATH LIBRDKAFKA_INCLUDE_DIR) @@ -52,10 +52,10 @@ if (NOT BUILD_OPTION_DOC_ONLY) if (DEFINED ENV{LIBRDKAFKA_LIBRARY_DIR}) set(LIBRDKAFKA_LIBRARY_DIR $ENV{LIBRDKAFKA_LIBRARY_DIR}) - else () + elseif (NOT DEFINED LIBRDKAFKA_LIBRARY_DIR) find_library(LIBRDKAFKA_LIB NAMES rdkafka - HINTS /usr/lib /usr/local/lib /opt/homebrew/lib) + HINTS /usr/lib /usr/local/lib /opt/homebrew/lib /home/linuxbrew/.linuxbrew/lib) cmake_path(GET LIBRDKAFKA_LIB PARENT_PATH LIBRDKAFKA_LIBRARY_DIR) endif () @@ -106,7 +106,7 @@ if (NOT BUILD_OPTION_DOC_ONLY) if (CMAKE_CXX_STANDARD EQUAL 14) if (DEFINED ENV{BOOST_ROOT}) set(Boost_INCLUDE_DIRS $ENV{BOOST_ROOT}/include) - else () + elseif (NOT DEFINED Boost_INCLUDE_DIRS) find_package(Boost) if (NOT Boost_FOUND) message(FATAL_ERROR "Cound not find library: boost!") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4b069a6e..4de5e248 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,7 +23,7 @@ link_directories(${Boost_LIBRARY_DIRS}) #--------------------------- if (DEFINED ENV{GTEST_ROOT}) set(GTEST_ROOT $ENV{GTEST_ROOT}) -else () +elseif (NOT DEFINED GTEST_ROOT) if (EXISTS "/usr/local/include/gtest/gtest.h") set(GTEST_ROOT /usr/local) elseif (EXISTS "/opt/homebrew/include/gtest/gtest.h") @@ -31,20 +31,39 @@ else () endif () endif () -if (NOT EXISTS "${GTEST_ROOT}/include/gtest/gtest.h") +# include dir +if (EXISTS "${GTEST_ROOT}/include/gtest/gtest.h") + set(GTEST_INCLUDE_DIR ${GTEST_ROOT}/include) +else () + if (NOT DEFINED GTEST_INCLUDE_DIR) + set(GTEST_INCLUDE_DIR ENV{GTEST_INCLUDE_DIR}) + endif() +endif () +if (NOT DEFINED GTEST_INCLUDE_DIR) message(FATAL_ERROR "Could not find headers for gtest!") +else() + message(STATUS "gtest include directory: ${GTEST_INCLUDE_DIR}") endif () -if (NOT (EXISTS "${GTEST_ROOT}/lib/libgtest_main.a" +if ((EXISTS "${GTEST_ROOT}/lib/libgtest_main.a" OR EXISTS "${GTEST_ROOT}/lib/libgtest_main.so" OR EXISTS "${GTEST_ROOT}/lib/gtest_main.lib")) + set(GTEST_LIBRARY_DIR ${GTEST_ROOT}/lib) +else () + if (NOT DEFINED GTEST_LIBRARY_DIR) + set(GTEST_LIBRARY_DIR ENV{GTEST_LIBRARY_DIR}) + endif() +endif () +if (NOT DEFINED GTEST_LIBRARY_DIR) message(FATAL_ERROR "Could not find library for gtest!") +else() + message(STATUS "gtest library directory: ${GTEST_LIBRARY_DIR}") endif () message(STATUS "googletest root directory: ${GTEST_ROOT}") -include_directories(SYSTEM ${GTEST_ROOT}/include) -link_directories(${GTEST_ROOT}/lib ${GTEST_ROOT}/bin) +include_directories(SYSTEM ${GTEST_INCLUDE_DIR}) +link_directories(${GTEST_LIBRARY_DIR} ${GTEST_ROOT}/bin) #--------------------------- diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index e4c8a0a7..09744d21 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -5,7 +5,7 @@ project("kafka-unit-test") #--------------------------- if (DEFINED ENV{RAPIDJSON_INCLUDE_DIRS}) set(RAPIDJSON_INCLUDE_DIRS $ENV{RAPIDJSON_INCLUDE_DIRS}) -else () +elseif (NOT DEFINED RAPIDJSON_INCLUDE_DIRS) find_file(RAPIDJSON_HEADER NAMES rapidjson.h HINTS /usr/include/rapidjson /usr/local/include/rapidjson /opt/homebrew/include/rapidjson)