Skip to content

Commit

Permalink
Modified CMake build for msys2/mingw64: check and use dependencies fo…
Browse files Browse the repository at this point in the history
…r libsndfile and use as link libraries where appropriate
  • Loading branch information
Steven Yi authored and Steven Yi committed Dec 30, 2015
1 parent 3aa76f6 commit 1b16064
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Expand Up @@ -419,6 +419,17 @@ if(NOT LIBSNDFILE_LIBRARY)
message(FATAL_ERROR "Csound requires the sndfile library")
endif()


if(WIN32 AND NOT MSVC)
find_library(OGG_LIB ogg)
find_library(VORBIS_LIB vorbis)
find_library(VORBISENC_LIB vorbisenc)
find_library(SPEEX_LIB speex)
find_library(FLAC_LIB FLAC)
set(LIBSNDFILE_SUPPORT_LIBS ${VORBIS_LIB} ${VORBISENC_LIB} ${SPEEX_LIB} ${FLAC_LIB} ${OGG_LIB}
)
endif()

find_path(SNDFILE_H_PATH sndfile.h)
if(SNDFILE_H_PATH)
include_directories(${SNDFILE_H_PATH})
Expand All @@ -432,6 +443,10 @@ if(NOT PTHREAD_LIBRARY AND WIN32)
find_library(PTHREAD_LIBRARY pthreadGC2)
endif()

if(NOT PTHREAD_LIBRARY AND WIN32)
find_library(PTHREAD_LIBRARY winpthread-1)
endif()

if(NOT PTHREAD_LIBRARY AND NOT EMSCRIPTEN)
message(FATAL_ERROR "Csound requires the pthread library")
endif()
Expand Down Expand Up @@ -1073,6 +1088,9 @@ endif()

if(WIN32)
list(APPEND libcsound_LIBS "${CSOUND_WINDOWS_LIBRARIES}")
if(NOT MSVC)
list(APPEND libcsound_LIBS "${LIBSNDFILE_SUPPORT_LIBS}")
endif()
endif()

if(CURL_FOUND)
Expand Down Expand Up @@ -1201,7 +1219,6 @@ endif()


add_compiler_flags(${libcsound_CFLAGS} TARGETS ${CSOUNDLIB})

target_link_libraries(${CSOUNDLIB} ${libcsound_LIBS})

set_target_properties(${CSOUNDLIB} PROPERTIES
Expand Down
5 changes: 5 additions & 0 deletions Opcodes/CMakeLists.txt
Expand Up @@ -88,6 +88,11 @@ elseif(LINUX)
endif()
else()
make_plugin(padsynth padsynth_gen.cpp)

if(WIN32 AND NOT MSVC)
set_target_properties(padsynth PROPERTIES COMPILE_FLAGS "-std=gnu++11"
LINK_FLAGS "-std=gnu++11")
endif()
endif()
endif()

Expand Down
23 changes: 19 additions & 4 deletions interfaces/CMakeLists.txt
Expand Up @@ -16,14 +16,20 @@ if(BUILD_CXX_INTERFACE)
csPerfThread.cpp
cs_glue.cpp
filebuilding.cpp)
set(libcsnd6_LIBS ${LIBSNDFILE_LIBRARY} )

set(libcsnd6_LIBS ${LIBSNDFILE_LIBRARY} )

if(WIN32 AND NOT MSVC)
list(APPEND libcsnd6_LIBS "${LIBSNDFILE_SUPPORT_LIBS}")
endif()

set(libcsnd6_CFLAGS "")
list(APPEND libcsnd6_LIBS ${CSOUNDLIB})

add_library(libcsnd6 SHARED ${libcsnd6_SRCS})
target_link_libraries(libcsnd6 ${libcsnd6_LIBS})
set_target_properties(libcsnd6 PROPERTIES
LINK_INTERFACE_LIBRARIES ""
INTERFACE_LINK_LIBRARIES ""
SOVERSION ${APIVERSION}
OUTPUT_NAME csnd6
RUNTIME_OUTPUT_DIRECTORY ${BUILD_BIN_DIR}
Expand Down Expand Up @@ -81,7 +87,11 @@ if(BUILD_PYTHON_INTERFACE OR BUILD_JAVA_INTERFACE OR BUILD_LUA_INTERFACE)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

if(WIN32)
if(NOT MSVC)
set(swigpython_LIBS ${CSOUNDLIB} ${LIBSNDFILE_LIBRARY} ${LIBSNDFILE_SUPPORT_LIBS} ${PYTHON_LIBRARY} libcsnd6)
else()
set(swigpython_LIBS ${CSOUNDLIB} ${LIBSNDFILE_LIBRARY} ${PYTHON_LIBRARY} libcsnd6)
endif()
else()
# Note: Do not link to PYTHON_LIBRARY so that it can be loaded in any python
set(swigpython_LIBS ${CSOUNDLIB} ${LIBSNDFILE_LIBRARY} libcsnd6)
Expand Down Expand Up @@ -125,8 +135,13 @@ if(BUILD_PYTHON_INTERFACE OR BUILD_JAVA_INTERFACE OR BUILD_LUA_INTERFACE)
message(STATUS "JNI INCLUDE set to ${JNI_INCLUDE_DIRS}")

if(WIN32)
set(swigjava_LIBS ${JNI_LIBRARIES} ${CSOUNDLIB}
${LIBSNDFILE_LIBRARY} libcsnd6)
if(NOT MSVC)
set(swigjava_LIBS ${JNI_LIBRARIES} ${CSOUNDLIB}
${LIBSNDFILE_LIBRARY} ${LIBSNDFILE_SUPPORT_LIBS} libcsnd6)
else()
set(swigjava_LIBS ${JNI_LIBRARIES} ${CSOUNDLIB}
${LIBSNDFILE_LIBRARY} libcsnd6)
endif()
elseif(APPLE)
set(swigjava_LIBS ${JAVA_VM_LIBRARY} ${CSOUNDLIB}
${LIBSNDFILE_LIBRARY} libcsnd6)
Expand Down
9 changes: 8 additions & 1 deletion util/CMakeLists.txt
Expand Up @@ -8,7 +8,14 @@ set(stdutil_SRCS
sndinfo.c srconv.c std_util.c xtrct.c
../SDIF/sdif.c)

make_plugin(stdutil "${stdutil_SRCS}" m ${LIBSNDFILE_LIBRARY})

if(WIN32 AND NOT MSVC)
make_plugin(stdutil "${stdutil_SRCS}" m
${LIBSNDFILE_LIBRARY} ${LIBSNDFILE_SUPPORT_LIBS})
else()
make_plugin(stdutil "${stdutil_SRCS}" m ${LIBSNDFILE_LIBRARY})
endif()

add_dependency_to_framework(stdutil ${LIBSNDFILE_LIBRARY})

if(BUILD_UTILITIES)
Expand Down

0 comments on commit 1b16064

Please sign in to comment.