Skip to content

Commit

Permalink
Add shared libraray and install support to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
StarGate01 authored and andreww committed Feb 14, 2021
1 parent a17367f commit e42cda9
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 95 deletions.
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OPTION(${PROJECT_NAME}_ENABLE_WCML "Enable/disable Chemical Markup Language outp
OPTION(${PROJECT_NAME}_ENABLE_WKML "Enable/disable Keyhole Markup Language output library" ON)
OPTION(${PROJECT_NAME}_ENABLE_DOM "Enable/disable Document Object Model input library" ON)
OPTION(${PROJECT_NAME}_ENABLE_EXAMPLES "Build examples" ON)
OPTION(BUILD_SHARED_LIBS, OFF)

#======================#
# set another compiler #
Expand Down Expand Up @@ -121,6 +122,22 @@ INCLUDE(${${PROJECT_NAME}_SOURCE_DIR}/cmake/CheckAbortIntrinsic.cmake)

SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FPPFLAGS}")

MACRO(MK_LIBS _NAME)
ADD_LIBRARY(
${PROJECT_NAME}_${_NAME}
${fox_${_NAME}_srcs}
${fox_${_NAME}_srcs_pp}
)
SET_PROPERTY(TARGET ${PROJECT_NAME}_${_NAME} PROPERTY POSITION_INDEPENDENT_CODE 1)
FOREACH(ARG IN ITEMS ${ARGN})
TARGET_LINK_LIBRARIES(
${PROJECT_NAME}_${_NAME}
${PROJECT_NAME}_${ARG}
)
ENDFOREACH()
INSTALL (TARGETS ${PROJECT_NAME}_${_NAME} DESTINATION lib)
ENDMACRO(MK_LIBS)

# Base library directories
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/fsys)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/utils)
Expand Down Expand Up @@ -176,7 +193,6 @@ ELSE()
GET_PROPERTY(THE_INCLUDE_DIRS GLOBAL PROPERTY INCLUDE_DIRECTORIES)
STRING(REPLACE "${${PROJECT_NAME}_SOURCE_DIR}/examples" "" NEW_INCLUDE_DIRS "${THE_INCLUDE_DIRS}")
SET_PROPERTY(GLOBAL PROPERTY INCLUDE_DIRECTORIES ${NEW_INCLUDE_DIRS})

ENDIF()


INSTALL(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION include)
13 changes: 1 addition & 12 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,4 @@ set(fox_common_srcs_pp
m_common_struct.F90
)

add_library(
${PROJECT_NAME}_common STATIC
${fox_common_srcs}
${fox_common_srcs_pp}
)

target_link_libraries(
${PROJECT_NAME}_common
${PROJECT_NAME}_utils
${PROJECT_NAME}_fsys
)

MK_LIBS(common utils fsys)
14 changes: 2 additions & 12 deletions dom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,9 @@ set(fox_dom_srcs
m_dom_utils.f90
)

add_library(
${PROJECT_NAME}_dom STATIC
${fox_dom_srcs}
${fox_dom_srcs_pp}
)
MK_LIBS(dom wxml sax)

## add_dependencies(
## fox_dom
## dom_generate
## )

target_link_libraries(
${PROJECT_NAME}_dom
${PROJECT_NAME}_wxml
${PROJECT_NAME}_sax
)
## )
5 changes: 1 addition & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,4 @@ include_directories(
${${PROJECT_NAME}_BINARY_DIR}/utils
${${PROJECT_NAME}_BINARY_DIR}/fsys
${${PROJECT_NAME}_BINARY_DIR}/sax
)



)
7 changes: 1 addition & 6 deletions fsys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,4 @@ set(fox_fsys_srcs_pp
fox_m_fsys_varstr.F90
)

add_library(
${PROJECT_NAME}_fsys STATIC
${fox_fsys_srcs}
${fox_fsys_srcs_pp}
)

MK_LIBS(fsys)
14 changes: 1 addition & 13 deletions sax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,4 @@ set(fox_sax_srcs_pp
m_sax_xml_source.F90
)


add_library(
${PROJECT_NAME}_sax STATIC
${fox_sax_srcs}
${fox_sax_srcs_pp}
)

target_link_libraries(
${PROJECT_NAME}_sax
${PROJECT_NAME}_common
${PROJECT_NAME}_utils
${PROJECT_NAME}_fsys
)
MK_LIBS(sax common utils fsys)
13 changes: 1 addition & 12 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,4 @@ set(fox_utils_srcs_pp
fox_m_utils_uuid.F90
)

add_library(
${PROJECT_NAME}_utils STATIC
${fox_utils_srcs}
${fox_utils_srcs_pp}
)

target_link_libraries(
${PROJECT_NAME}_utils
${PROJECT_NAME}_fsys
)


MK_LIBS(utils fsys)
12 changes: 1 addition & 11 deletions wcml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,4 @@ set(fox_wcml_srcs_pp
m_wcml_inputdec.F90
)

add_library(
${PROJECT_NAME}_wcml STATIC
${fox_wcml_srcs}
${fox_wcml_srcs_pp}
)

target_link_libraries(
${PROJECT_NAME}_wcml
${PROJECT_NAME}_utils
${PROJECT_NAME}_wxml
)
MK_LIBS(wcml utils wxml)
13 changes: 1 addition & 12 deletions wkml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,4 @@ set(fox_wkml_srcs_pp
m_wkml_chart.F90
)

add_library(
${PROJECT_NAME}_wkml STATIC
${fox_wkml_srcs}
${fox_wkml_srcs_pp}
)

target_link_libraries(
${PROJECT_NAME}_wkml
${PROJECT_NAME}_utils
${PROJECT_NAME}_wxml
)

MK_LIBS(wkml utils wxml)
12 changes: 1 addition & 11 deletions wxml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,5 @@ set(fox_wxml_srcs_pp
m_wxml_escape.F90
m_wxml_overloads.F90
)

add_library(
${PROJECT_NAME}_wxml STATIC
${fox_wxml_srcs}
${fox_wxml_srcs_pp}
)

target_link_libraries(
${PROJECT_NAME}_wxml
${PROJECT_NAME}_common
${PROJECT_NAME}_fsys
)
MK_LIBS(wxml common fsys)

0 comments on commit e42cda9

Please sign in to comment.