I found a mistake which resulted in a compile error when I tried it with
gcc, added an install option in the cmake file and split it into libgig
& libakai so it's the same as the makefile.
On 12/02/2019 17:37, Christian Schoenebeck wrote:
Looks fine to me. Just one last thing: You added CMake files and I wonder what's
better, placing those CMake files directly at the individual locations like you
did, or rather putting them into a dedicated subdir like "msvc" altogether.
The thing is, obviously right now we do not support cmake on Linux etc., so it
is not a real issue yet. But one day somebody will ask for compiling libgig
with cmake on other platforms as well.
It's very easy to put it in a separate dir, let me know if you prefer that.
Obviously the best way would be sharing the CMake files among all platforms and
just wrapping the architecture/compiler specific portions with conditions.
Would that be easily possible? Last time I looked into this with cmake I think
there were some substantial limitations, but I can't remember anymore what
exactly.
I also work on lmms and there we compile for windows, mac, linux. For
windows we can cross-compile with mingw or use msvc directly. This is
done with shared cmake files for all combinations. If there's a
limitation, I haven't encountered it so far.
It's easy to do with conditionals in cmake. What's more tricky is using
the right conditionals. For example, you have to make a distinction
between platform and compiler. So if the variable WIN32 is defined you
can't assume it's msvc that's being used since we can also cross-compile.
There's also several combinations possible of which systems you want to
support for finding the libraries you link to (pkg-config, cmake
config,...) . You have very few dependencies so that won't be a problem.
It depends which combinations you want to support and how far you are
prepared to go into the rabbit hole.
diff --git CMakeLists.txt CMakeLists.txt
new file mode 100644
index 0000000..e3d7929
--- /dev/null
+++ CMakeLists.txt
@@ -0,0 +1,103 @@
+cmake_minimum_required(VERSION 3.0)
+project(libgig)
+
+if(NOT MSVC)
+ message(FATAL_ERROR "Please use configure and make, this cmake file is
only to generate msvc solution files")
+endif()
+
+set(BUILD_TOOLS ON CACHE BOOL "Build the tools")
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+
+find_path(CPPUNIT_INCLUDE_DIRS cppunit/TestFixture.h)
+find_library(CPPUNIT_LIBRARIES_DEBUG cppunitd_dll)
+find_library(CPPUNIT_LIBRARIES_RELEASE cppunit_dll)
+set(CPPUNIT_LIBRARIES
+ $<$<CONFIG:Debug>:${CPPUNIT_LIBRARIES_DEBUG}>
+ $<$<CONFIG:RelWithDebInfo>:${CPPUNIT_LIBRARIES_RELEASE}>
+ $<$<CONFIG:Release>:${CPPUNIT_LIBRARIES_RELEASE}>
+ $<$<CONFIG:MinSizeRel>:${CPPUNIT_LIBRARIES_RELEASE}>)
+
+find_package(LibSndFile)
+
+if(CPPUNIT_LIBRARIES AND CPPUNIT_INCLUDE_DIRS)
+ set(CPPUNIT_FOUND TRUE)
+else()
+ message("cppunit not found. Testcases will not be built.")
+endif()
+
+#get version from configure.ac
+file(STRINGS configure.ac VERSION_STRINGS REGEX
"^m4_define\\(libgig_release.*\\)$")
+
+string(REGEX MATCH "libgig_release_major, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
+set(VERSION_MAJOR ${CMAKE_MATCH_1})
+string(REGEX MATCH "libgig_release_minor, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
+set(VERSION_MINOR ${CMAKE_MATCH_1})
+string(REGEX MATCH "libgig_release_build, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
+set(VERSION_BUILD ${CMAKE_MATCH_1})
+
+set(PACKAGE_NAME "libgig")
+
+set(LIBGIG_SOURCES
+ src/DLS.cpp
+ src/gig.cpp
+ src/helper.cpp
+ src/Korg.cpp
+ src/RIFF.cpp
+ src/Serialization.cpp
+ src/SF.cpp
+ src/typeinfo.cpp
+ win32/dllmain.cpp)
+
+set(LIBGIG_HEADERS
+ src/DLS.h
+ src/gig.h
+ src/RIFF.h
+ src/SF.h
+ src/Korg.h
+ src/Serialization.h)
+
+set(LIBAKAI_SOURCES
+ src/Akai.cpp
+ win32/dllmain.cpp)
+
+set(LIBAKAI_HEADERS
+ src/Akai.h)
+
+add_library(libgig SHARED ${LIBGIG_SOURCES})
+set_target_properties(libgig PROPERTIES PUBLIC_HEADER "${LIBGIG_HEADERS}")
+target_compile_definitions(libgig PRIVATE NOMINMAX)
+target_compile_definitions(libgig PRIVATE PACKAGE="${PACKAGE_NAME}"
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
+target_link_libraries(libgig Rpcrt4.lib dbghelp.lib)
+set_target_properties(libgig PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+
+add_library(libakai SHARED ${LIBAKAI_SOURCES})
+set_target_properties(libakai PROPERTIES PUBLIC_HEADER "${LIBAKAI_HEADERS}")
+target_compile_definitions(libakai PRIVATE NOMINMAX)
+target_compile_definitions(libakai PRIVATE PACKAGE="${PACKAGE_NAME}"
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
+#target_link_libraries(libakai Rpcrt4.lib dbghelp.lib)
+set_target_properties(libakai PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+
+if(CPPUNIT_FOUND)
+ add_subdirectory(src/testcases)
+endif(CPPUNIT_FOUND)
+
+if(BUILD_TOOLS)
+ add_subdirectory(src/tools)
+endif(BUILD_TOOLS)
+
+install(TARGETS libgig EXPORT LibGigConfig
+ LIBRARY DESTINATION lib
+ RUNTIME DESTINATION bin
+ PUBLIC_HEADER DESTINATION include/libgig)
+install(EXPORT LibGigConfig DESTINATION share/libgig)
+
+install(TARGETS libakai EXPORT LibAkaiConfig
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ PUBLIC_HEADER DESTINATION include/libgig)
+install(EXPORT LibAkaiConfig DESTINATION share/libgig)
+
diff --git README README
index 433c35e..fb37e25 100644
--- README
+++ README
@@ -149,8 +149,30 @@ Compiling for Linux
On success, the resulting rpm(s) can usually be found under the proper
"/usr/src/<rpmdir>/RPMS/<arch>" directory.
-Compiling for Windows
-=====================
+Compiling for Windows using CMake
+=================================
+The easiest way is to compile is to use vcpkg
(https://github.com/Microsoft/vcpkg)
+to install libsndfile (required) and cppunit (optional). In the vcpkg install
dir
+type:
+.\vcpkg.exe install libsndfile cppunit [--triplet x64-windows]
+
+This should install the libraries in vcpkg, add the triplet option if you wish
to
+get the 64bit libraries.
+
+In an empty directory type:
+cmake <libgig source dir> -DCMAKE_TOOLCHAIN_FILE=<vcpkg
dir>\scripts\buildsystems\vcpkg.cmake
+[-G"Visual Studio 15 2017 Win64"]
+
+Use the -G option to select the visual studio version and whether to compile
for
+64bits.
+
+This will create libgig.sln file which you can open in visual studio or you
can use
+the following command line to compile:
+
+cmake --build . --config <Release|Debug|MinRelSize|RelWithDebInfo>
+
+Compiling for Windows using Dev-C++
+===================================
libgig and its tools can be compiled for Windows using Bloodshed Dev-C++,
which is a free (GPL) C++ integrated development environment for Windows.
diff --git src/Akai.cpp src/Akai.cpp
index fc4558d..3f4ae7d 100644
--- src/Akai.cpp
+++ src/Akai.cpp
@@ -24,8 +24,10 @@
#include <stdio.h>
#include <string.h>
+#ifndef _MSC_VER
#include <unistd.h>
#include <fcntl.h>
+#endif
#if defined(_CARBON_) || defined(__APPLE__)
# if defined (__GNUC__) && (__GNUC__ >= 4)
# include <sys/disk.h>
diff --git src/Akai.h src/Akai.h
index 759648f..6815029 100644
--- src/Akai.h
+++ src/Akai.h
@@ -43,8 +43,9 @@
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
+#ifndef _MSC_VER
#include <sys/fcntl.h>
-
+#endif
#if defined(_CARBON_) || defined(__APPLE__) || LINUX
# include <sys/ioctl.h>
# include <unistd.h>
diff --git src/RIFF.h src/RIFF.h
index 558935c..7801107 100644
--- src/RIFF.h
+++ src/RIFF.h
@@ -54,7 +54,7 @@
# include <unistd.h>
#endif // POSIX
-#ifdef _MSC_VER
+#if defined _MSC_VER && _MSC_VER < 1600
// Visual C++ 2008 doesn't have stdint.h
typedef __int8 int8_t;
typedef __int16 int16_t;
diff --git src/Serialization.cpp src/Serialization.cpp
index b586691..2581a54 100644
--- src/Serialization.cpp
+++ src/Serialization.cpp
@@ -31,8 +31,12 @@
#include <assert.h>
#include <string.h> // for memcpy()
#include <stdlib.h> // for atof()
+#ifdef _MSC_VER
+#include <windows.h>
+#include <dbghelp.h>
+#else
#include <cxxabi.h>
-
+#endif
#include "helper.h"
#define LIBGIG_EPOCH_TIME ((time_t)0)
@@ -403,10 +407,23 @@ namespace Serialization {
*/
String DataType::customTypeName(bool demangle) const {
if (!demangle) return m_customTypeName;
+#ifdef _MSC_VER
+ const size_t MAXLENGTH = 1024;
+ char result[MAXLENGTH];
+
+ //Skip the first char
+ size_t size = UnDecorateSymbolName(m_customTypeName.c_str() +1,
result, MAXLENGTH, UNDNAME_32_BIT_DECODE | UNDNAME_NO_ARGUMENTS);
+ if (size)
+ {
+ return result;
+ }
+ return m_customTypeName;
+#else
int status;
const char* result =
abi::__cxa_demangle(m_customTypeName.c_str(), 0, 0, &status);
return (status == 0) ? result : m_customTypeName;
+#endif
}
// *************** Member ***************
diff --git src/Serialization.h src/Serialization.h
index f96df0e..98af4ac 100644
--- src/Serialization.h
+++ src/Serialization.h
@@ -441,8 +441,7 @@ namespace Serialization {
template<typename T>
static String rawCppTypeNameOf(const T& data) {
#if defined _MSC_VER // Microsoft compiler ...
- # warning type_info::raw_name() demangling has not been tested yet
with Microsoft compiler! Feedback appreciated!
- String name = typeid(data).raw_name(); //NOTE: I haven't checked
yet what MSC actually outputs here exactly
+ String name = typeid(data).raw_name();
#else // i.e. especially GCC and clang ...
String name = typeid(data).name();
#endif
diff --git src/helper.h src/helper.h
index 65a481e..8777ac1 100644
--- src/helper.h
+++ src/helper.h
@@ -29,17 +29,26 @@
#include <sstream>
#include <algorithm>
-#if defined(WIN32) && !HAVE_CONFIG_H
+#if defined(WIN32) && !HAVE_CONFIG_H && !defined(_MSC_VER)
# include "../win32/libgig_private.h" // like config.h, automatically
generated by Dev-C++
# define PACKAGE "libgig"
# define VERSION VER_STRING // VER_STRING defined in libgig_private.h
#endif // WIN32
-#if HAVE_CONFIG_H /*&& !HAVE_VASPRINTF*/ && defined(WIN32)
+#if (HAVE_CONFIG_H /*&& !HAVE_VASPRINTF*/ && defined(WIN32)) ||
defined(_MSC_VER)
# include <stdarg.h>
int vasprintf(char** ret, const char* format, va_list arg);
#endif
+#if defined(_MSC_VER)
+#if _MSC_VER < 1900
+#error versions prior to msvc 2015 have not been tested
+#else
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+#endif
+
#include "RIFF.h"
// *************** Helper Functions **************
diff --git src/testcases/CMakeLists.txt src/testcases/CMakeLists.txt
new file mode 100644
index 0000000..4b276ac
--- /dev/null
+++ src/testcases/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(TEST_SOURCES
+ main.cpp
+ GigWriteTest.cpp)
+
+
+add_executable(gigwritetest ${TEST_SOURCES})
+target_link_libraries(gigwritetest PRIVATE libgig ${CPPUNIT_LIBRARIES})
+
+target_include_directories(gigwritetest PRIVATE ${CPPUNIT_INCLUDE_DIRS})
diff --git src/testcases/GigWriteTest.cpp src/testcases/GigWriteTest.cpp
index 2ca5c87..97f5da0 100644
--- src/testcases/GigWriteTest.cpp
+++ src/testcases/GigWriteTest.cpp
@@ -207,7 +207,9 @@ void GigWriteTest::testArticulationsOfCreatedGigFile() {
CPPUNIT_ASSERT(pRegion->VelocityRange.low == iInstrument - 1);
CPPUNIT_ASSERT(pRegion->VelocityRange.high == iInstrument);
CPPUNIT_ASSERT(pRegion->KeyGroup == iInstrument - 1);
- gig::DimensionRegion* pDimensionRegion =
pRegion->GetDimensionRegionByValue((uint[8]){0,0,0,0,0,0,0,0});
+ //gig::DimensionRegion* pDimensionRegion =
pRegion->GetDimensionRegionByValue((uint[8]){0,0,0,0,0,0,0,0});
+ const uint dimensionRegion[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ gig::DimensionRegion* pDimensionRegion =
pRegion->GetDimensionRegionByValue(dimensionRegion);
CPPUNIT_ASSERT(pDimensionRegion);
CPPUNIT_ASSERT(pDimensionRegion->pSample->pInfo->Name ==
sOughtToBe);
iInstrument++;
diff --git src/tools/CMakeLists.txt src/tools/CMakeLists.txt
new file mode 100644
index 0000000..d400482
--- /dev/null
+++ src/tools/CMakeLists.txt
@@ -0,0 +1,24 @@
+
+macro(add_tool NAME)
+ add_executable(${NAME} ${NAME}.cpp)
+ target_link_libraries(${NAME} PRIVATE libgig)
+endmacro(add_tool)
+
+add_executable(akaidump akaidump.cpp)
+target_link_libraries(akaidump PRIVATE libakai)
+#add_executable(akaiextract akaiextract.cpp)
+#target_link_libraries(akaiextract PRIVATE libakai)
+
+add_tool(dlsdump)
+#add_tool(gig2mono)
+#add_tool(gig2stereo)
+add_tool(gigdump)
+add_tool(gigextract)
+target_link_libraries(gigextract PRIVATE sndfile-shared)
+add_tool(gigmerge)
+add_tool(korg2gig)
+add_tool(korgdump)
+add_tool(rifftree)
+add_tool(sf2dump)
+add_tool(sf2extract)
+target_link_libraries(sf2extract PRIVATE sndfile-shared)
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel