Skip to content

Commit 9f71c98

Browse files
committed
Better support for building without vcpkg
1 parent 0b07fea commit 9f71c98

File tree

4 files changed

+204
-4
lines changed

4 files changed

+204
-4
lines changed

CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
cmake_minimum_required(VERSION 3.30)
2+
3+
if(WIN32)
4+
option(VCPKG "Use vcpkg for dependencies" ON)
5+
else()
6+
option(VCPKG "Use vcpkg for dependencies" OFF)
7+
endif()
8+
9+
if(VCPKG)
10+
set(VCPKG_LIBRARY_LINKAGE "static")
11+
endif()
12+
13+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
14+
215
set(CMAKE_CXX_STANDARD 14)
316
set(CMAKE_CXX_STANDARD_REQUIRED True)
4-
set(VCPKG_TARGET_TRIPLET x64-windows-static)
517

618
project(ArrowVortex)
719

@@ -10,9 +22,9 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release)
1022
include_directories("${PROJECT_SOURCE_DIR}/src")
1123

1224
find_package(Freetype REQUIRED)
13-
find_package(mad CONFIG REQUIRED)
25+
find_package(MAD REQUIRED)
1426
find_package(Ogg CONFIG REQUIRED)
15-
find_package(Vorbis CONFIG REQUIRED)
27+
find_package(Vorbis REQUIRED)
1628
find_package(OpenGL REQUIRED)
1729

1830
add_subdirectory(src/Core)

cmake/FindMAD.cmake

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright (C) 2001-2020 Mixxx Development Team
2+
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
3+
# later version. See the LICENSE.txt file for details.
4+
5+
#[=======================================================================[.rst:
6+
FindMAD
7+
-------
8+
9+
Finds the MAD library.
10+
11+
Imported Targets
12+
^^^^^^^^^^^^^^^^
13+
14+
This module provides the following imported targets, if found:
15+
16+
``MAD::MAD``
17+
The MAD library
18+
19+
Result Variables
20+
^^^^^^^^^^^^^^^^
21+
22+
This will define the following variables:
23+
24+
``MAD_FOUND``
25+
True if the system has the MAD library.
26+
``MAD_INCLUDE_DIRS``
27+
Include directories needed to use MAD.
28+
``MAD_LIBRARIES``
29+
Libraries needed to link to MAD.
30+
``MAD_DEFINITIONS``
31+
Compile definitions needed to use MAD.
32+
33+
Cache Variables
34+
^^^^^^^^^^^^^^^
35+
36+
The following cache variables may also be set:
37+
38+
``MAD_INCLUDE_DIR``
39+
The directory containing ``mad.h``.
40+
``MAD_LIBRARY``
41+
The path to the MAD library.
42+
43+
#]=======================================================================]
44+
45+
find_package(PkgConfig QUIET)
46+
if(PkgConfig_FOUND)
47+
pkg_check_modules(PC_MAD QUIET mad)
48+
endif()
49+
50+
find_path(MAD_INCLUDE_DIR
51+
NAMES mad.h
52+
PATHS ${PC_MAD_INCLUDE_DIRS}
53+
PATH_SUFFIXES mad
54+
DOC "MAD include directory")
55+
mark_as_advanced(MAD_INCLUDE_DIR)
56+
57+
find_library(MAD_LIBRARY
58+
NAMES mad
59+
PATHS ${PC_MAD_LIBRARY_DIRS}
60+
DOC "MAD library"
61+
)
62+
mark_as_advanced(MAD_LIBRARY)
63+
64+
include(FindPackageHandleStandardArgs)
65+
find_package_handle_standard_args(
66+
MAD
67+
DEFAULT_MSG
68+
MAD_LIBRARY
69+
MAD_INCLUDE_DIR
70+
)
71+
72+
if(MAD_FOUND)
73+
set(MAD_LIBRARIES "${MAD_LIBRARY}")
74+
set(MAD_INCLUDE_DIRS "${MAD_INCLUDE_DIR}")
75+
set(MAD_DEFINITIONS ${PC_MAD_CFLAGS_OTHER})
76+
77+
if(NOT TARGET MAD::MAD)
78+
add_library(MAD::MAD UNKNOWN IMPORTED)
79+
set_target_properties(MAD::MAD
80+
PROPERTIES
81+
IMPORTED_LOCATION "${MAD_LIBRARY}"
82+
INTERFACE_COMPILE_OPTIONS "${PC_MAD_CFLAGS_OTHER}"
83+
INTERFACE_INCLUDE_DIRECTORIES "${MAD_INCLUDE_DIR}"
84+
)
85+
endif()
86+
endif()

cmake/FindVorbis.cmake

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Copyright (C) 2001-2020 Mixxx Development Team
2+
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
3+
# later version. See the LICENSE.txt file for details.
4+
5+
#[=======================================================================[.rst:
6+
FindVorbis
7+
----------
8+
9+
Finds the Vorbis library.
10+
11+
Result Variables
12+
^^^^^^^^^^^^^^^^
13+
14+
This will define the following variables:
15+
16+
``Vorbis_FOUND``
17+
True if the system has the OggVorbis library.
18+
``Vorbis_INCLUDE_DIRS``
19+
Include directories needed to use OggVorbis.
20+
``Vorbis_LIBRARIES``
21+
Libraries needed to link to OggVorbis.
22+
23+
Cache Variables
24+
^^^^^^^^^^^^^^^
25+
26+
The following cache variables may also be set:
27+
28+
``Vorbis_vorbis_INCLUDE_DIR``
29+
The directory containing ``vorbis/vorbis.h``.
30+
``Vorbis_vorbisenc_INCLUDE_DIR``
31+
The directory containing ``vorbis/vorbisenc.h``.
32+
``Vorbis_vorbisfile_INCLUDE_DIR``
33+
The directory containing ``vorbis/vorbisfile.h``.
34+
``Vorbis_vorbis_LIBRARY``
35+
The path to the vorbis library.
36+
``Vorbis_vorbisenc_LIBRARY``
37+
The path to the vorbisenc library.
38+
``Vorbis_vorbisfile_LIBRARY``
39+
The path to the vorbisfile library.
40+
``Vorbis_LIBRARIES``
41+
Libraries needed to link to vorbis.
42+
43+
#]=======================================================================]
44+
45+
find_path(Vorbis_vorbis_INCLUDE_DIR
46+
NAMES vorbis/codec.h
47+
DOC "Vorbis include directory"
48+
)
49+
mark_as_advanced(Vorbis_vorbis_INCLUDE_DIR)
50+
51+
find_path(Vorbis_vorbisenc_INCLUDE_DIR
52+
NAMES vorbis/vorbisenc.h
53+
DOC "Vorbisenc include directory"
54+
)
55+
mark_as_advanced(Vorbis_vorbisenc_INCLUDE_DIR)
56+
57+
find_path(Vorbis_vorbisfile_INCLUDE_DIR
58+
NAMES vorbis/vorbisfile.h
59+
DOC "Vorbisfile include directory"
60+
)
61+
mark_as_advanced(Vorbis_vorbisfile_INCLUDE_DIR)
62+
63+
find_library(Vorbis_vorbis_LIBRARY
64+
NAMES vorbis
65+
DOC "Vorbis library")
66+
mark_as_advanced(Vorbis_vorbis_LIBRARY)
67+
68+
find_library(Vorbis_vorbisenc_LIBRARY
69+
NAMES vorbisenc
70+
DOC "Vorbisenc library")
71+
mark_as_advanced(Vorbis_vorbisenc_LIBRARY)
72+
73+
find_library(Vorbis_vorbisfile_LIBRARY
74+
NAMES vorbisfile
75+
DOC "Vorbisfile library")
76+
mark_as_advanced(Vorbis_vorbisfile_LIBRARY)
77+
78+
if(NOT Vorbis_FIND_COMPONENTS)
79+
set(Vorbis_FIND_COMPONENTS "vorbis;vorbisenc;vorbisfile")
80+
endif()
81+
82+
foreach(component ${Vorbis_FIND_COMPONENTS})
83+
if(Vorbis_${component}_INCLUDE_DIR AND Vorbis_${component}_LIBRARY)
84+
set(Vorbis_${component}_FOUND TRUE)
85+
if(NOT TARGET Vorbis::${component})
86+
add_library(Vorbis::${component} UNKNOWN IMPORTED)
87+
set_target_properties(Vorbis::${component}
88+
PROPERTIES
89+
IMPORTED_LOCATION "${Vorbis_${component}_LIBRARY}"
90+
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_${component}_INCLUDE_DIR}"
91+
)
92+
endif()
93+
else()
94+
set(Vorbis_${component}_FOUND FALSE)
95+
endif()
96+
endforeach()
97+
98+
include(FindPackageHandleStandardArgs)
99+
find_package_handle_standard_args(Vorbis
100+
REQUIRED_VARS Vorbis_vorbis_INCLUDE_DIR Vorbis_vorbis_LIBRARY
101+
HANDLE_COMPONENTS
102+
)

src/Editor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ file(GLOB SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
22
file(GLOB INC "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
33

44
add_library(Editor STATIC ${SRC} ${INC})
5-
target_link_libraries(Editor PRIVATE Core Dialogs mad::mad Managers Simfile System Vorbis::vorbisfile Ogg::ogg)
5+
target_link_libraries(Editor PRIVATE Core Dialogs MAD::MAD Managers Simfile System Vorbis::vorbisfile Ogg::ogg)

0 commit comments

Comments
 (0)