-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
136 lines (118 loc) · 4.21 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
cmake_minimum_required(VERSION 3.16)
project(
musicmove
VERSION 1.1.0
DESCRIPTION "Rename and move music files into a structure that aligns with their metadata tags"
)
set(PROJECT_HOMEPAGE_URL "https://github.com/xsco/musicmove")
set(PROJECT_BUGREPORT_URL "https://github.com/xsco/musicmove/issues")
# Include additional modules.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Require C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if (MSVC)
add_compile_options("/W4" "/wd4251" "/wd4275" "$<$<CONFIG:RELEASE>:/O2>")
# Ask MSVC to populate the __cplusplus macro properly.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
else ()
add_compile_options("-Wall" "$<$<CONFIG:RELEASE>:-O3>")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-stdlib=libc++")
endif ()
endif ()
# Require boost program_options, filesystem, locale
find_package(
Boost 1.71
REQUIRED
COMPONENTS program_options system filesystem locale unit_test_framework)
# Require taglib 1.x
find_package(Taglib 1.11.1 REQUIRED)
# Require chaiscript
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(chaiscript/chaiscript.hpp ChaiScript_FOUND)
if (!ChaiScript_FOUND)
message(FATAL_ERROR "Cannot find <chaiscript/chaiscript.hpp>, which is a required dependency")
endif ()
set(PACKAGE ${CMAKE_PROJECT_NAME})
set(PACKAGE_STRING ${CMAKE_PROJECT_NAME})
set(PACKAGE_BUGREPORT ${PROJECT_BUGREPORT_URL})
configure_file(src/config.hpp.in src/config.hpp)
add_compile_definitions(PATH_CONVERSION_DEFAULT_VALUE="windows-ascii")
add_library(
libmusicmove
STATIC
src/context.hpp
src/format.cpp
src/format.hpp
src/format_easytag.cpp
src/metadata.cpp
src/metadata.hpp
src/metadata_base.hpp
src/metadata_flac.hpp
src/metadata_mp4.hpp
src/metadata_mpeg.hpp
src/metadata_ogg_vorbis.hpp
src/move.cpp
src/move.hpp
src/script_runner.cpp
src/script_runner.hpp
)
target_include_directories(libmusicmove PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/src")
target_link_libraries(
libmusicmove
Boost::program_options Boost::system Boost::filesystem Boost::locale
Taglib::Taglib
)
add_executable(
musicmove
src/musicmove.cpp
)
target_link_libraries(
musicmove
libmusicmove
)
# man page generation
add_custom_command(
TARGET musicmove
POST_BUILD
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/musicmove.1
COMMAND help2man ${CMAKE_CURRENT_BINARY_DIR}/musicmove > ${CMAKE_CURRENT_BINARY_DIR}/musicmove.1
)
include(CTest)
add_executable(
test_metadata
src/metadata_test.cpp
src/metadata.cpp
)
target_compile_definitions(test_metadata PUBLIC -DTESTDATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/testdata)
target_link_libraries(test_metadata PUBLIC libmusicmove Boost::unit_test_framework)
add_test(NAME test_metadata COMMAND test_metadata)
add_executable(
test_format
src/format_test.cpp
src/metadata_mock.cpp
src/format.cpp
src/format_easytag.cpp
src/format.hpp)
target_compile_definitions(test_format PUBLIC -DTESTDATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/testdata)
target_link_libraries(test_format PUBLIC libmusicmove Boost::unit_test_framework)
add_test(NAME test_format COMMAND test_format)
add_executable(
test_script_runner
src/script_runner_test.cpp
src/metadata_mock.cpp)
target_compile_definitions(test_script_runner PUBLIC -DTESTDATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/testdata)
target_link_libraries(test_script_runner PUBLIC libmusicmove Boost::unit_test_framework)
add_test(NAME test_script_runner COMMAND test_script_runner)
add_executable(
test_move
src/move_test.cpp
src/format_mock.cpp
src/metadata_mock.cpp)
target_compile_definitions(test_move PUBLIC -DTESTDATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/testdata)
target_link_libraries(test_move PUBLIC libmusicmove Boost::unit_test_framework)
add_test(NAME test_move COMMAND test_move)
# Install stage
install(TARGETS musicmove)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/musicmove.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)