Skip to content

Commit

Permalink
Merge pull request #6 from kgerheiser/feature/cmake-fixes
Browse files Browse the repository at this point in the history
CMake fixes from Kyle concerning the new shared_all library.
  • Loading branch information
GeorgeGayno-NOAA authored Apr 22, 2020
2 parents 0a3a2c1 + 6394312 commit e9c4ec3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 32 deletions.
24 changes: 9 additions & 15 deletions sorc/fre-nctools.fd/shared_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@ set(c_src
read_mosaic.c
tool_util.c)

add_definitions(-Duse_netCDF)

if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS "-traceback")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG
"-O0"
)
set(CMAKE_C_FLAGS_DEBUG "-O0")
elseif(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(CMAKE_C_FLAGS " ")
set(CMAKE_C_FLAGS_RELEASE " ")
set(CMAKE_C_FLAGS_DEBUG " "
)
set(CMAKE_C_FLAGS_DEBUG " ")
endif()

set(lib_name shared_all)
add_library(${lib_name} STATIC ${c_src})
target_include_directories(
${lib_name} PRIVATE)
target_link_libraries(
${lib_name}
NetCDF::NetCDF_C)
add_library(shared_all STATIC ${c_src})
target_compile_definitions(shared_all PRIVATE use_netCDF)

target_include_directories(shared_all PUBLIC ${CURRENT_SOURCE_DIR})

target_link_libraries(shared_all NetCDF::NetCDF_C)

install(TARGETS ${lib_name} RUNTIME DESTINATION ./)
install(TARGETS shared_all RUNTIME DESTINATION lib)
25 changes: 8 additions & 17 deletions sorc/fre-nctools.fd/tools/make_hgrid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,21 @@ set(c_src
create_lonlat_grid.c
make_hgrid.c)

set ( PROJECT_LINK_LIBS libshared_all.a )
link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../shared_lib)
include_directories(../../shared_lib)

if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS "-traceback")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG
"-O0"
)
set(CMAKE_C_FLAGS_DEBUG "-O0")

elseif(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(CMAKE_C_FLAGS " ")
set(CMAKE_C_FLAGS_RELEASE " ")
set(CMAKE_C_FLAGS_DEBUG " "
)
set(CMAKE_C_FLAGS_DEBUG " ")
endif()

set(exe_name make_hgrid)
add_executable(${exe_name} ${c_src})
target_include_directories(
${exe_name} PRIVATE)
target_link_libraries(
${exe_name}
${PROJECT_LINK_LIBS}
add_executable(make_hgrid ${c_src})

target_link_libraries(make_hgrid
shared_all
NetCDF::NetCDF_C)

install(TARGETS ${exe_name} RUNTIME DESTINATION exec)
install(TARGETS make_hgrid RUNTIME DESTINATION exec)

0 comments on commit e9c4ec3

Please sign in to comment.