Build both static and shared libraries.
First many other projects do this, and it seems a good choice. Due mainly to windows where the static and shared libraries have the same name, appended an 's' to the static library. The tidy console app will use the static library, since to build the man page tidy may need to be run before the shared libraries are installed. And this makes the windows tidy exe a stand-alone app. No DLL install issue. This addresses issue #194, and possibly #190
This commit is contained in:
parent
bb35166ed0
commit
efb8e37664
|
@ -20,7 +20,7 @@ list(GET VERSION_LIST 2 TIDY_POINT_VERSION)
|
||||||
|
|
||||||
# Allow developer to select is Dynamic or static library built
|
# Allow developer to select is Dynamic or static library built
|
||||||
set( LIB_TYPE STATIC ) # set default static
|
set( LIB_TYPE STATIC ) # set default static
|
||||||
option( BUILD_SHARED_LIB "Set ON to build Shared (DLL) Library" OFF )
|
option( BUILD_SHARED_LIB "Set ON to build Shared (DLL) Library" ON )
|
||||||
option( BUILD_TAB2SPACE "Set ON to build utility app, tab2space" OFF )
|
option( BUILD_TAB2SPACE "Set ON to build utility app, tab2space" OFF )
|
||||||
option( BUILD_SAMPLE_CODE "Set ON to build the sample code" OFF )
|
option( BUILD_SAMPLE_CODE "Set ON to build the sample code" OFF )
|
||||||
if (NOT MAN_INSTALL_DIR)
|
if (NOT MAN_INSTALL_DIR)
|
||||||
|
@ -117,22 +117,13 @@ if (MSVC)
|
||||||
list(APPEND CFILES ${SRCDIR}/sprtf.c)
|
list(APPEND CFILES ${SRCDIR}/sprtf.c)
|
||||||
list(APPEND LIBHFILES ${SRCDIR}/sprtf.h)
|
list(APPEND LIBHFILES ${SRCDIR}/sprtf.h)
|
||||||
endif ()
|
endif ()
|
||||||
set(name lib-tidy)
|
#######################################
|
||||||
add_library ( ${name} ${LIB_TYPE} ${CFILES} ${HFILES} ${LIBHFILES} )
|
# Always build the STATIC library
|
||||||
|
set(name tidy-static)
|
||||||
|
add_library ( ${name} STATIC ${CFILES} ${HFILES} ${LIBHFILES} )
|
||||||
set_target_properties( ${name} PROPERTIES
|
set_target_properties( ${name} PROPERTIES
|
||||||
OUTPUT_NAME ${LIB_NAME}
|
OUTPUT_NAME ${LIB_NAME}s
|
||||||
)
|
)
|
||||||
set_target_properties( ${name} PROPERTIES
|
|
||||||
VERSION ${LIBTIDY_VERSION}
|
|
||||||
SOVERSION ${TIDY_MAJOR_VERSION} )
|
|
||||||
if (BUILD_SHARED_LIB)
|
|
||||||
set_target_properties( ${name} PROPERTIES
|
|
||||||
COMPILE_FLAGS "-DBUILD_SHARED_LIB"
|
|
||||||
)
|
|
||||||
set_target_properties( ${name} PROPERTIES
|
|
||||||
COMPILE_FLAGS "-DBUILDING_SHARED_LIB"
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
list ( APPEND add_LIBS ${name} )
|
list ( APPEND add_LIBS ${name} )
|
||||||
install(TARGETS ${name}
|
install(TARGETS ${name}
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
|
@ -140,9 +131,29 @@ install(TARGETS ${name}
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
)
|
)
|
||||||
install( FILES ${HFILES} DESTINATION include )
|
install( FILES ${HFILES} DESTINATION include )
|
||||||
|
########################################
|
||||||
|
# if user option still on
|
||||||
|
if (BUILD_SHARED_LIB)
|
||||||
|
set(name tidy-share)
|
||||||
|
add_library ( ${name} SHARED ${CFILES} ${HFILES} ${LIBHFILES} )
|
||||||
|
set_target_properties( ${name} PROPERTIES
|
||||||
|
OUTPUT_NAME ${LIB_NAME} )
|
||||||
|
set_target_properties( ${name} PROPERTIES
|
||||||
|
VERSION ${LIBTIDY_VERSION}
|
||||||
|
SOVERSION ${TIDY_MAJOR_VERSION} )
|
||||||
|
set_target_properties( ${name} PROPERTIES
|
||||||
|
COMPILE_FLAGS "-DBUILD_SHARED_LIB" )
|
||||||
|
set_target_properties( ${name} PROPERTIES
|
||||||
|
COMPILE_FLAGS "-DBUILDING_SHARED_LIB" )
|
||||||
|
install(TARGETS ${name}
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
### main executable
|
### main executable - linked with STATIC library
|
||||||
set(name ${LIB_NAME})
|
set(name ${LIB_NAME})
|
||||||
set ( BINDIR console )
|
set ( BINDIR console )
|
||||||
add_executable( ${name} ${BINDIR}/tidy.c )
|
add_executable( ${name} ${BINDIR}/tidy.c )
|
||||||
|
@ -150,11 +161,6 @@ target_link_libraries( ${name} ${add_LIBS} )
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
||||||
endif ()
|
endif ()
|
||||||
if (BUILD_SHARED_LIB)
|
|
||||||
set_target_properties( ${name} PROPERTIES
|
|
||||||
COMPILE_FLAGS "-DBUILD_SHARED_LIB"
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
install (TARGETS ${name} DESTINATION bin)
|
install (TARGETS ${name} DESTINATION bin)
|
||||||
|
|
||||||
if (BUILD_TAB2SPACE)
|
if (BUILD_TAB2SPACE)
|
||||||
|
|
Loading…
Reference in a new issue