/[svn]/libgig/trunk/CMakeLists.txt
ViewVC logotype

Contents of /libgig/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4063 - (show annotations) (download)
Fri Oct 6 15:36:02 2023 UTC (7 months, 1 week ago) by schoenebeck
File MIME type: text/plain
File size: 4575 byte(s)
Fix build errors on Windows (patches by Ross Maxx):

* src/Serialization.h: Fix 'ssize_t' on MSVC. MSVC compiler doesn't
  contain 'ssize_t' but it contains 'SSIZE_T'.

* CMake: Raise minimum requirement to C++11 as libgig code in general
  already depends on this C++ standard version.

* CMake: Fix installation rules for libakai.

* CMake: Raise minimum requirement to CMake 3.1.

* Bumped version (4.3.0.svn35).

1 cmake_minimum_required(VERSION 3.1)
2 project(libgig)
3
4 if(NOT MSVC)
5 message(FATAL_ERROR "Please use configure and make, this cmake file is currently only to generate msvc solution files")
6 endif()
7
8 #To force the compiler to use C++ 11
9 set(CMAKE_CXX_STANDARD 11)
10 set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
11
12
13 #configuration options
14 set(LIBGIG_BUILD_TOOLS ON CACHE BOOL "Build the extra tools")
15 set(LIBGIG_ENABLE_TESTING ON CACHE BOOL "Build the test cases")
16 set(LIBGIG_BUILD_SHARED ${BUILD_SHARED_LIBS} CACHE BOOL "build dynamic libraries")
17
18 set(BUILD_SHARED_LIBS ${LIBGIG_BUILD_SHARED})
19
20 if(LIBGIG_ENABLE_TESTING)
21 enable_testing()
22 endif()
23
24 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
25 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
26 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
27
28 #TODO: this is written for vcpkg cppunit install
29 #if you're adding other platform and package managers it's probably better to put everything in FindCppUnit.cmake
30 #and replace everything here with a simple find_package(CppUnit)
31 if(WIN32)
32 find_path(CPPUNIT_INCLUDE_DIRS cppunit/TestFixture.h)
33 find_library(CPPUNIT_LIBRARIES_DEBUG cppunitd_dll)
34 find_library(CPPUNIT_LIBRARIES_RELEASE cppunit_dll)
35 mark_as_advanced(CPPUNIT_INCLUDE_DIRS CPPUNIT_LIBRARIES_DEBUG CPPUNIT_LIBRARIES_RELEASE)
36
37 if(CPPUNIT_LIBRARIES_DEBUG AND CPPUNIT_LIBRARIES_RELEASE AND CPPUNIT_INCLUDE_DIRS)
38 set(CPPUNIT_FOUND TRUE)
39 set(CPPUNIT_LIBRARIES
40 $<$<CONFIG:Debug>:${CPPUNIT_LIBRARIES_DEBUG}>
41 $<$<CONFIG:RelWithDebInfo>:${CPPUNIT_LIBRARIES_RELEASE}>
42 $<$<CONFIG:Release>:${CPPUNIT_LIBRARIES_RELEASE}>
43 $<$<CONFIG:MinSizeRel>:${CPPUNIT_LIBRARIES_RELEASE}>)
44 else()
45 message("cppunit not found. Testcases will not be built.")
46 endif()
47 endif(WIN32)
48
49 if(LIBGIG_BUILD_TOOLS)
50 find_package(LibSndFile)
51 endif()
52
53 #get version from configure.ac
54 #have to make a slight detour since I cannot get the cmake regex subgroup to work with file
55 file(STRINGS configure.ac VERSION_STRINGS REGEX "^m4_define\\(libgig_release.*\\)$")
56
57 string(REGEX MATCH "libgig_release_major, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
58 set(VERSION_MAJOR ${CMAKE_MATCH_1})
59 string(REGEX MATCH "libgig_release_minor, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
60 set(VERSION_MINOR ${CMAKE_MATCH_1})
61 string(REGEX MATCH "libgig_release_build, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
62 set(VERSION_BUILD ${CMAKE_MATCH_1})
63
64 set(PACKAGE_NAME "libgig")
65
66 set(LIBGIG_HEADERS
67 src/DLS.h
68 src/gig.h
69 src/RIFF.h
70 src/SF.h
71 src/Korg.h
72 src/Serialization.h)
73
74 #libgig core library
75 add_library(libgig
76 src/DLS.cpp
77 src/gig.cpp
78 src/helper.cpp
79 src/Korg.cpp
80 src/RIFF.cpp
81 src/Serialization.cpp
82 src/SF.cpp
83 src/typeinfo.cpp)
84 if(WIN32)
85 target_sources(libgig PRIVATE win32/dllmain.cpp)
86 endif()
87
88 set_target_properties(libgig PROPERTIES PUBLIC_HEADER "${LIBGIG_HEADERS}")
89 target_compile_definitions(libgig PRIVATE PACKAGE="${PACKAGE_NAME}" VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
90 target_include_directories(libgig PUBLIC $<INSTALL_INTERFACE:include>)
91 if(MSVC)
92 target_compile_definitions(libgig PRIVATE NOMINMAX)
93 endif()
94 if(WIN32)
95 target_link_libraries(libgig Rpcrt4.lib dbghelp.lib)
96 endif()
97 if(BUILD_SHARED_LIBS AND MSVC)
98 set_target_properties(libgig PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
99 endif()
100
101 #libakai library
102 add_library(libakai src/Akai.cpp)
103 if(WIN32)
104 target_sources(libakai PRIVATE win32/dllmain.cpp)
105 endif()
106 set_target_properties(libakai PROPERTIES PUBLIC_HEADER src/Akai.h)
107 target_include_directories(libakai PUBLIC $<INSTALL_INTERFACE:include>)
108 target_compile_definitions(libakai PRIVATE PACKAGE="${PACKAGE_NAME}" VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
109
110 if(MSVC)
111 target_compile_definitions(libakai PRIVATE NOMINMAX)
112 endif()
113 if(BUILD_SHARED_LIBS AND MSVC)
114 set_target_properties(libakai PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
115 endif()
116 if(WIN32)
117 target_link_libraries(libakai Rpcrt4.lib )
118 endif()
119
120 if(CPPUNIT_FOUND AND LIBGIG_ENABLE_TESTING)
121 add_subdirectory(src/testcases)
122 endif()
123
124 if(LIBGIG_BUILD_TOOLS)
125 add_subdirectory(src/tools)
126 endif(LIBGIG_BUILD_TOOLS)
127
128 #installation
129 #It also creates a *-config.cmake files so other cmake users can include it more easily into their projects
130 install(TARGETS libgig EXPORT libgig-config
131 LIBRARY DESTINATION lib
132 ARCHIVE DESTINATION lib
133 RUNTIME DESTINATION bin
134 PUBLIC_HEADER DESTINATION include/libgig)
135
136 install(TARGETS libakai EXPORT libgig-config
137 LIBRARY DESTINATION lib
138 ARCHIVE DESTINATION lib
139 RUNTIME DESTINATION bin
140 PUBLIC_HEADER DESTINATION include/libgig)
141 install(EXPORT libgig-config NAMESPACE libgig:: DESTINATION share/libgig)
142

  ViewVC Help
Powered by ViewVC