Update CMakeLists.txt

This commit is contained in:
张壹 2021-01-11 08:43:34 +08:00
parent b58aadc715
commit ffc36c31f5

View File

@ -2,12 +2,34 @@ cmake_minimum_required(VERSION 3.15.2 FATAL_ERROR)
project(GMT_API_EX VERSION 0.1.0 LANGUAGES CXX) project(GMT_API_EX VERSION 0.1.0 LANGUAGES CXX)
include_directories(/usr/local/include/gmt) if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
find_library(GMT_LIB gmt /usr/local/lib) message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
include_directories(/usr/local/include/gmt)
find_library(GMT_LIB gmt /usr/local/lib)
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
include_directories(/usr/local/include/gmt)
find_library(GMT_LIB gmt /usr/local/lib)
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
include_directories(C:/programs/gmt6/include/gmt)
find_library(GMT_LIB gmt C:/programs/gmt6/lib)
else()
message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
include_directories(/usr/local/include/gmt)
find_library(GMT_LIB gmt /usr/local/lib)
endif()
message(STATUS "GMT library found as: " ${GMT_LIB})
macro(add_example name file) macro(add_example name file)
add_executable(${name} ${file}.cpp) add_executable(${name} ${file}.cpp)
target_link_libraries(${name} PUBLIC ${GMT_LIB}) if(WIN32)
target_link_libraries(${name} PRIVATE ${GMT_LIB})
else()
target_link_libraries(${name} PUBLIC ${GMT_LIB})
endif(WIN32)
endmacro() endmacro()
add_example(ex1 src/gridding) add_example(ex1 src/gridding)