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

Contents of /libgig/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4093 - (show annotations) (download)
Mon Feb 12 12:26:06 2024 UTC (2 weeks, 2 days ago) by schoenebeck
File MIME type: text/plain
File size: 4589 byte(s)
* Move system dependent type and macro definitions into a shared header
  file sysdef.h (fixes compilation error with MSVC).

* Bumped version (4.4.0.svn2).

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/sysdef.h
68 src/DLS.h
69 src/gig.h
70 src/RIFF.h
71 src/SF.h
72 src/Korg.h
73 src/Serialization.h)
74
75 #libgig core library
76 add_library(libgig
77 src/DLS.cpp
78 src/gig.cpp
79 src/helper.cpp
80 src/Korg.cpp
81 src/RIFF.cpp
82 src/Serialization.cpp
83 src/SF.cpp
84 src/typeinfo.cpp)
85 if(WIN32)
86 target_sources(libgig PRIVATE win32/dllmain.cpp)
87 endif()
88
89 set_target_properties(libgig PROPERTIES PUBLIC_HEADER "${LIBGIG_HEADERS}")
90 target_compile_definitions(libgig PRIVATE PACKAGE="${PACKAGE_NAME}" VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
91 target_include_directories(libgig PUBLIC $<INSTALL_INTERFACE:include>)
92 if(MSVC)
93 target_compile_definitions(libgig PRIVATE NOMINMAX)
94 endif()
95 if(WIN32)
96 target_link_libraries(libgig Rpcrt4.lib dbghelp.lib)
97 endif()
98 if(BUILD_SHARED_LIBS AND MSVC)
99 set_target_properties(libgig PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
100 endif()
101
102 #libakai library
103 add_library(libakai src/Akai.cpp)
104 if(WIN32)
105 target_sources(libakai PRIVATE win32/dllmain.cpp)
106 endif()
107 set_target_properties(libakai PROPERTIES PUBLIC_HEADER src/Akai.h)
108 target_include_directories(libakai PUBLIC $<INSTALL_INTERFACE:include>)
109 target_compile_definitions(libakai PRIVATE PACKAGE="${PACKAGE_NAME}" VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
110
111 if(MSVC)
112 target_compile_definitions(libakai PRIVATE NOMINMAX)
113 endif()
114 if(BUILD_SHARED_LIBS AND MSVC)
115 set_target_properties(libakai PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
116 endif()
117 if(WIN32)
118 target_link_libraries(libakai Rpcrt4.lib )
119 endif()
120
121 if(CPPUNIT_FOUND AND LIBGIG_ENABLE_TESTING)
122 add_subdirectory(src/testcases)
123 endif()
124
125 if(LIBGIG_BUILD_TOOLS)
126 add_subdirectory(src/tools)
127 endif(LIBGIG_BUILD_TOOLS)
128
129 #installation
130 #It also creates a *-config.cmake files so other cmake users can include it more easily into their projects
131 install(TARGETS libgig EXPORT libgig-config
132 LIBRARY DESTINATION lib
133 ARCHIVE DESTINATION lib
134 RUNTIME DESTINATION bin
135 PUBLIC_HEADER DESTINATION include/libgig)
136
137 install(TARGETS libakai EXPORT libgig-config
138 LIBRARY DESTINATION lib
139 ARCHIVE DESTINATION lib
140 RUNTIME DESTINATION bin
141 PUBLIC_HEADER DESTINATION include/libgig)
142 install(EXPORT libgig-config NAMESPACE libgig:: DESTINATION share/libgig)
143

  ViewVC Help
Powered by ViewVC