Issue #326 - Allow linkage choice TIDY_CONSOLE_SHARED
This commit is contained in:
parent
34eb16b5da
commit
e5038f0bc9
|
@ -36,8 +36,8 @@ else ()
|
||||||
message(FATAL_ERROR "*** FAILED to get a DATE from version.txt!")
|
message(FATAL_ERROR "*** FAILED to get a DATE from version.txt!")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# BY default, BOTH library types build, Allow turning OFF shared if not neede
|
# By default, BOTH library types built, Allow turning OFF shared if not needed
|
||||||
set( LIB_TYPE STATIC ) # set default static
|
set( LIB_TYPE STATIC ) # set default message
|
||||||
option( BUILD_SHARED_LIB "Set OFF to NOT build shared library" ON )
|
option( BUILD_SHARED_LIB "Set OFF to NOT build shared 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 )
|
||||||
|
@ -45,6 +45,13 @@ if (NOT MAN_INSTALL_DIR)
|
||||||
set(MAN_INSTALL_DIR share/man/man1)
|
set(MAN_INSTALL_DIR share/man/man1)
|
||||||
endif ()
|
endif ()
|
||||||
option( BUILD_DOCUMENTATION "Set ON to build the documentation" OFF )
|
option( BUILD_DOCUMENTATION "Set ON to build the documentation" OFF )
|
||||||
|
# Issue #326 - Allow linkage choice of console app tidy
|
||||||
|
option( TIDY_CONSOLE_SHARED "Set ON to link with shared(DLL) lib." OFF )
|
||||||
|
if (TIDY_CONSOLE_SHARED)
|
||||||
|
if (NOT BUILD_SHARED_LIB)
|
||||||
|
message(FATAL_ERROR "Enable shared build for this tidy linkage!")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set( WARNING_FLAGS -Wall )
|
set( WARNING_FLAGS -Wall )
|
||||||
|
@ -157,7 +164,9 @@ add_library ( ${name} STATIC ${CFILES} ${HFILES} ${LIBHFILES} )
|
||||||
set_target_properties( ${name} PROPERTIES
|
set_target_properties( ${name} PROPERTIES
|
||||||
OUTPUT_NAME ${LIB_NAME}s
|
OUTPUT_NAME ${LIB_NAME}s
|
||||||
)
|
)
|
||||||
list ( APPEND add_LIBS ${name} )
|
if (NOT TIDY_CONSOLE_SHARED) # user wants default static linkage
|
||||||
|
list ( APPEND add_LIBS ${name} )
|
||||||
|
endif ()
|
||||||
install(TARGETS ${name}
|
install(TARGETS ${name}
|
||||||
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
|
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
|
||||||
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
||||||
|
@ -183,10 +192,13 @@ if (BUILD_SHARED_LIB)
|
||||||
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
||||||
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
||||||
)
|
)
|
||||||
|
if (TIDY_CONSOLE_SHARED) # user wants shared/dll linkage
|
||||||
|
list ( APPEND add_LIBS ${name} )
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
### main executable - linked with STATIC library
|
### main executable - linked with STATIC/SHARED 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 )
|
||||||
|
@ -194,6 +206,10 @@ 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 (NOT TIDY_CONSOLE_SHARED)
|
||||||
|
set_target_properties( ${name} PROPERTIES
|
||||||
|
COMPILE_FLAGS "-DTIDY_STATIC" )
|
||||||
|
endif ()
|
||||||
install (TARGETS ${name} DESTINATION bin)
|
install (TARGETS ${name} DESTINATION bin)
|
||||||
|
|
||||||
if (BUILD_TAB2SPACE)
|
if (BUILD_TAB2SPACE)
|
||||||
|
@ -202,7 +218,7 @@ if (BUILD_TAB2SPACE)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
|
||||||
endif ()
|
endif ()
|
||||||
# no INSTALL of this 'local' tool
|
# no INSTALL of this 'local' tool - use depreciated
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (BUILD_SAMPLE_CODE)
|
if (BUILD_SAMPLE_CODE)
|
||||||
|
|
Loading…
Reference in a new issue