Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
Strip CMakeLists.txt
  • Loading branch information
zvezdochiot committed Jun 11, 2018
1 parent 8522925 commit 996fc69
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 104 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
212 changes: 111 additions & 101 deletions CMakeLists.txt → src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ PROJECT(unsf C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# UnSF version
SET(PNAME "unsf")
SET(VERSION_MAJOR 1)
SET(VERSION_MINOR 1)
SET(VERSION_RELEASE 0)
SET(UNSF_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}")

# Library versions
SET(SOVERSION 1)
SET(VERSION 1.1.0)
SET(PVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}")

# Find Macros
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
Expand All @@ -35,6 +32,8 @@ IF (POLICY CMP0042)
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF ()

OPTION(STATIC_ENABLE "Build static library" ON)

IF (OPENBSD) # Set RPATH for OpenBSD so unsf can find libunsf.so
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand Down Expand Up @@ -111,13 +110,13 @@ TEST_BIG_ENDIAN(WORDS_BIGENDIAN)

# General setup
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_SOURCE_DIR}/include")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${unsf_BINARY_DIR}")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINARY_DIR}")

# build setup
SET(unsf_library_SRCS
SET(library_SRCS
libunsf.c
)
SET(unsf_library_HDRS
SET(library_HDRS
libunsf.h
strtok_r.h
)
Expand All @@ -127,7 +126,7 @@ IF (MSVC)
ELSE()
SET(GETOPT)
ENDIF()
SET(unsf_executable_SRCS
SET(executable_SRCS
${GETOPT}
unsf.c
)
Expand All @@ -136,155 +135,164 @@ SET(unsf_executable_SRCS
SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}")

# set our library names
IF (WIN32 AND NOT CMAKE_COMPILER_IS_MINGW) # windows uses *.lib for both static and dynamic, workaround
SET(LIBRARY_DYN_NAME "unsf")
SET(LIBRARY_STATIC_NAME "unsf_static")
ELSE () # everyone else uses .a and .so
SET(LIBRARY_DYN_NAME "unsf")
SET(LIBRARY_STATIC_NAME "unsf")
ENDIF ()
IF (STATIC_ENABLE)
MESSAGE ( STATUS "Static library and tools build" )
# set our library names
IF (WIN32 AND NOT CMAKE_COMPILER_IS_MINGW) # windows uses *.lib for both static and dynamic, workaround
SET(LIBRARY_STATIC_NAME "${PNAME}_static")
ELSE () # everyone else uses .a and .so
SET(LIBRARY_STATIC_NAME "${PNAME}")
ENDIF ()

# static library
ADD_LIBRARY(libunsf_static STATIC
${unsf_library_SRCS}
${unsf_library_HDRS}
)
TARGET_LINK_LIBRARIES(libunsf_static
${M_LIBRARY}
)
SET_TARGET_PROPERTIES(libunsf_static PROPERTIES
OUTPUT_NAME ${LIBRARY_STATIC_NAME} CLEAN_DIRECT_OUTPUT 1
COMPILE_DEFINITIONS UNSF_BUILD
)
# static library
ADD_LIBRARY(lib${PNAME}_static STATIC
${library_SRCS}
${library_HDRS}
)
TARGET_LINK_LIBRARIES(lib${PNAME}_static
${M_LIBRARY}
)
SET_TARGET_PROPERTIES(lib${PNAME}_static PROPERTIES
OUTPUT_NAME ${LIBRARY_STATIC_NAME} CLEAN_DIRECT_OUTPUT 1
COMPILE_DEFINITIONS UNSF_BUILD
)
ENDIF (STATIC_ENABLE)

# dynamic library
ADD_LIBRARY(libunsf_dynamic SHARED
${unsf_library_SRCS}
${unsf_library_HDRS}
ADD_LIBRARY(lib${PNAME}_dynamic SHARED
${library_SRCS}
${library_HDRS}
)
TARGET_LINK_LIBRARIES(libunsf_dynamic
TARGET_LINK_LIBRARIES(lib${PNAME}_dynamic
${M_LIBRARY}
)
SET_TARGET_PROPERTIES(libunsf_dynamic PROPERTIES
SOVERSION ${SOVERSION}
VERSION ${VERSION}
OUTPUT_NAME ${LIBRARY_DYN_NAME} CLEAN_DIRECT_OUTPUT 1
SET_TARGET_PROPERTIES(lib${PNAME}_dynamic PROPERTIES
SOVERSION ${VERSION_MAJOR}
VERSION ${PVERSION}
OUTPUT_NAME ${PNAME} CLEAN_DIRECT_OUTPUT 1
)
IF (WIN32)
SET_TARGET_PROPERTIES(libunsf_dynamic PROPERTIES
SET_TARGET_PROPERTIES(lib${PNAME}_dynamic PROPERTIES
DEFINE_SYMBOL DLL_EXPORT
COMPILE_DEFINITIONS UNSF_BUILD
)
ELSEIF (HAVE_VISIBILITY_HIDDEN AND HAVE_VISIBILITY_DEFAULT) # GCC, Clang
SET_TARGET_PROPERTIES(libunsf_dynamic PROPERTIES
SET_TARGET_PROPERTIES(lib${PNAME}_dynamic PROPERTIES
COMPILE_DEFINITIONS "UNSF_BUILD;SYM_VISIBILITY"
COMPILE_FLAGS "-fvisibility=hidden"
)
#ELSEIF (HAVE_LDSCOPE_HIDDEN AND HAVE_VISIBILITY_DEFAULT) # SunPro (__SUNPRO_C >= 0x590)
# SET_TARGET_PROPERTIES(libunsf_dynamic PROPERTIES
# SET_TARGET_PROPERTIES(lib${PNAME}_dynamic PROPERTIES
# COMPILE_DEFINITIONS "UNSF_BUILD;SYM_VISIBILITY"
# COMPILE_FLAGS "-xldscope=hidden"
# )
ELSEIF (HAVE_LDSCOPE_HIDDEN AND HAVE_LDSCOPE_GLOBAL) # SunPro (__SUNPRO_C >= 0x550)
SET_TARGET_PROPERTIES(libunsf_dynamic PROPERTIES
SET_TARGET_PROPERTIES(lib${PNAME}_dynamic PROPERTIES
COMPILE_DEFINITIONS "UNSF_BUILD;SYM_LDSCOPE"
COMPILE_FLAGS "-xldscope=hidden"
)
ELSE ()
SET_TARGET_PROPERTIES(libunsf_dynamic PROPERTIES
SET_TARGET_PROPERTIES(lib${PNAME}_dynamic PROPERTIES
COMPILE_DEFINITIONS UNSF_BUILD
)
ENDIF ()

# Set our default and then look at the possible locations
SET(UNSFLIB "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.so")
SET(UNSFLIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
SET(PLIB "${CMAKE_BINARY_DIR}/lib${PNAME}.so")
SET(PLIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")

# MS Visual Studio
IF (MSVC)
SET(UNSFLIB "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_DYN_NAME}.lib")
SET(UNSFLIBSTATIC "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_STATIC_NAME}.lib")
SET(PLIB "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${PNAME}.lib")
SET(PLIBSTATIC "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${LIBRARY_STATIC_NAME}.lib")
ENDIF (MSVC)

# MinGW or MinGW-w64
IF (CMAKE_COMPILER_IS_MINGW)
SET(UNSFLIB "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dll.a")
SET(UNSFDLL "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dll")
SET(UNSFLIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
SET(PLIB "${CMAKE_BINARY_DIR}/lib${PNAME}.dll.a")
SET(PDLL "${CMAKE_BINARY_DIR}/lib${PNAME}.dll")
SET(PLIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
ENDIF (CMAKE_COMPILER_IS_MINGW)

# Apple's Xcode
IF (CMAKE_GENERATOR STREQUAL "Xcode")
SET(UNSFLIB "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_DYN_NAME}.dylib")
SET(UNSFLIBSTATIC "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_STATIC_NAME}.a")
SET(PLIB "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${PNAME}.dylib")
SET(PLIBSTATIC "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${LIBRARY_STATIC_NAME}.a")
ELSEIF (APPLE) # Apple's CLI default
SET(UNSFLIB "${CMAKE_BINARY_DIR}/lib${LIBRARY_DYN_NAME}.dylib")
SET(UNSFLIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
SET(PLIB "${CMAKE_BINARY_DIR}/lib${PNAME}.dylib")
SET(PLIBSTATIC "${CMAKE_BINARY_DIR}/lib${LIBRARY_STATIC_NAME}.a")
ENDIF (CMAKE_GENERATOR STREQUAL "Xcode")

# unsf.exe
ADD_EXECUTABLE(unsf
${unsf_executable_SRCS}
${unsf_executable_HDRS}
ADD_EXECUTABLE(${PNAME}
${executable_SRCS}
${executable_HDRS}
)
ADD_DEPENDENCIES(unsf libunsf_dynamic)
TARGET_LINK_LIBRARIES(unsf
${UNSFLIB}
ADD_DEPENDENCIES(${PNAME} lib${PNAME}_dynamic)
TARGET_LINK_LIBRARIES(${PNAME}
${PLIB}
)

# unsf-static.exe
ADD_EXECUTABLE(unsf-static
${unsf_executable_SRCS}
)
ADD_DEPENDENCIES(unsf-static libunsf_static)
SET_TARGET_PROPERTIES(unsf-static PROPERTIES
COMPILE_DEFINITIONS UNSF_STATIC
)
TARGET_LINK_LIBRARIES(unsf-static
${UNSFLIBSTATIC}
${M_LIBRARY}
)
IF (STATIC_ENABLE)
# ${PNAME}-static.exe
ADD_EXECUTABLE(${PNAME}-static
${executable_SRCS}
)
ADD_DEPENDENCIES(${PNAME}-static lib${PNAME}_static)
SET_TARGET_PROPERTIES(${PNAME}-static PROPERTIES
COMPILE_DEFINITIONS UNSF_STATIC
)
TARGET_LINK_LIBRARIES(${PNAME}-static
${PLIBSTATIC}
${M_LIBRARY}
)
ENDIF (STATIC_ENABLE)

# convenience variables
SET(UNSFLIB_INSTALLDIR "lib${LIB_SUFFIX}")
SET(UNSFDLL_INSTALLDIR "bin${LIB_SUFFIX}")
SET(LIB_INSTALLDIR "lib${LIB_SUFFIX}")
SET(DLL_INSTALLDIR "bin${LIB_SUFFIX}")

# add multiarch folder, if needed
IF (CMAKE_LIBRARY_ARCHITECTURE)
SET(UNSFLIB_INSTALLDIR "${UNSFLIB_INSTALLDIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
SET(UNSFDLL_INSTALLDIR "${UNSFDLL_INSTALLDIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
SET(LIB_INSTALLDIR "${LIB_INSTALLDIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
SET(DLL_INSTALLDIR "${DLL_INSTALLDIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
ENDIF ()

# prepare pkg-config file
SET(UNSFLIB_PREFIX "${CMAKE_INSTALL_PREFIX}")
SET(UNSFLIB_LIBDIR "${UNSFLIB_INSTALLDIR}")
CONFIGURE_FILE("unsf.pc.in" "${CMAKE_BINARY_DIR}/unsf.pc" @ONLY)
SET(PLIB_PREFIX "${CMAKE_INSTALL_PREFIX}")
SET(PLIB_LIBDIR "${LIB_INSTALLDIR}")
CONFIGURE_FILE("${PNAME}.pc.in" "${CMAKE_BINARY_DIR}/${PNAME}.pc" @ONLY)

# install target (*nix OSes)
IF (UNIX AND NOT APPLE)
INSTALL(TARGETS libunsf_static DESTINATION ${UNSFLIB_INSTALLDIR})
INSTALL(TARGETS unsf-static DESTINATION bin)
INSTALL(TARGETS libunsf_dynamic DESTINATION ${UNSFLIB_INSTALLDIR})
INSTALL(TARGETS unsf DESTINATION bin)
INSTALL(FILES ${CMAKE_BINARY_DIR}/unsf.pc DESTINATION "${UNSFLIB_INSTALLDIR}/pkgconfig")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/libunsf.h DESTINATION include)
IF (STATIC_ENABLE)
INSTALL(TARGETS lib${PNAME}_static DESTINATION ${LIB_INSTALLDIR})
INSTALL(TARGETS ${PNAME}-static DESTINATION bin)
ENDIF (STATIC_ENABLE)
INSTALL(TARGETS lib${PNAME}_dynamic DESTINATION ${LIB_INSTALLDIR})
INSTALL(TARGETS ${PNAME} DESTINATION bin)
INSTALL(FILES ${CMAKE_BINARY_DIR}/${PNAME}.pc DESTINATION "${LIB_INSTALLDIR}/pkgconfig")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib${PNAME}.h DESTINATION include)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/../man/man1/${PNAME}.1 DESTINATION share/man/man1)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/../LICENSE ${CMAKE_SOURCE_DIR}/../README.md DESTINATION share/doc/${PNAME})
ENDIF (UNIX AND NOT APPLE)

# install target (Windows: MinGW or MinGW-w64)
IF (WIN32 AND CMAKE_COMPILER_IS_MINGW)
IF ("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
MESSAGE("INSTALL PREFIX IS EMPTY")
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/unsf_lib" CACHE STRING "Install Prefix" FORCE)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${PNAME}_lib" CACHE STRING "Install Prefix" FORCE)
MESSAGE("INSTALL PREFIX NOW: ${CMAKE_INSTALL_PREFIX}")
ENDIF()
INSTALL(TARGETS libunsf_static DESTINATION ${UNSFLIB_INSTALLDIR})
INSTALL(TARGETS unsf-static DESTINATION bin)
INSTALL(FILES ${UNSFLIB} DESTINATION ${UNSFLIB_INSTALLDIR})
INSTALL(FILES ${UNSFDLL} DESTINATION ${UNSFDLL_INSTALLDIR})
INSTALL(TARGETS unsf DESTINATION bin)
INSTALL(FILES ${CMAKE_BINARY_DIR}/unsf.pc DESTINATION "${UNSFLIB_INSTALLDIR}/pkgconfig")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/libunsf.h DESTINATION include)
IF (STATIC_ENABLE)
INSTALL(TARGETS lib${PNAME}_static DESTINATION ${LIB_INSTALLDIR})
INSTALL(TARGETS ${PNAME}-static DESTINATION bin)
ENDIF (STATIC_ENABLE)
INSTALL(FILES ${PLIB} DESTINATION ${LIB_INSTALLDIR})
INSTALL(FILES ${PDLL} DESTINATION ${DLL_INSTALLDIR})
INSTALL(TARGETS ${PNAME} DESTINATION bin)
INSTALL(FILES ${CMAKE_BINARY_DIR}/${PNAME}.pc DESTINATION "${LIB_INSTALLDIR}/pkgconfig")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib${PNAME}.h DESTINATION include)
ENDIF (WIN32 AND CMAKE_COMPILER_IS_MINGW)

IF (WIN32 AND MSVC)
Expand All @@ -294,13 +302,15 @@ IF (WIN32 AND MSVC)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)")
endforeach (OUTPUTCONFIG)

SET_TARGET_PROPERTIES(unsf PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
SET_TARGET_PROPERTIES(unsf PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
TARGET_COMPILE_DEFINITIONS(unsf PRIVATE $<$<CONFIG:Release>:_CONSOLE>)
TARGET_COMPILE_DEFINITIONS(unsf PRIVATE $<$<CONFIG:MinSizeRel>:_CONSOLE>)

SET_TARGET_PROPERTIES(unsf-static PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
SET_TARGET_PROPERTIES(unsf-static PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
TARGET_COMPILE_DEFINITIONS(unsf-static PRIVATE $<$<CONFIG:Release>:_CONSOLE>)
TARGET_COMPILE_DEFINITIONS(unsf-static PRIVATE $<$<CONFIG:MinSizeRel>:_CONSOLE>)
SET_TARGET_PROPERTIES(${PNAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
SET_TARGET_PROPERTIES(${PNAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
TARGET_COMPILE_DEFINITIONS(${PNAME} PRIVATE $<$<CONFIG:Release>:_CONSOLE>)
TARGET_COMPILE_DEFINITIONS(${PNAME} PRIVATE $<$<CONFIG:MinSizeRel>:_CONSOLE>)

IF (STATIC_ENABLE)
SET_TARGET_PROPERTIES(${PNAME}-static PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
SET_TARGET_PROPERTIES(${PNAME}-static PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
TARGET_COMPILE_DEFINITIONS(${PNAME}-static PRIVATE $<$<CONFIG:Release>:_CONSOLE>)
TARGET_COMPILE_DEFINITIONS(${PNAME}-static PRIVATE $<$<CONFIG:MinSizeRel>:_CONSOLE>)
ENDIF (STATIC_ENABLE)
ENDIF ()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions unsf.pc.in → src/unsf.pc.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
prefix=@UNSFLIB_PREFIX@
prefix=@PLIB_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@UNSFLIB_LIBDIR@
libdir=${exec_prefix}/@PLIB_LIBDIR@
includedir=${exec_prefix}/include

Name: UnSF
Description: UnSF converts soundfonts into gus patch files
Version: @UNSF_VERSION@
Version: @PVERSION@
URL: https://www.mindwerks.net/projects/unsf/

Libs: -L${libdir} -lunsf
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 996fc69

Please sign in to comment.