Skip to content

Commit 7b54b76

Browse files
authored
Separated project into tests and library (#11)
* Separated project into tests and library * Change CMakeLists.txt
1 parent d4db7f4 commit 7b54b76

File tree

7 files changed

+21
-6
lines changed

7 files changed

+21
-6
lines changed

CMakeLists.txt

100644100755
+11-5
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ set(CMAKE_CXX_STANDARD 20)
44
set(CMAKE_CXX_STANDARD_REQUIRED ON)
55
set(CMAKE_CXX_EXTENSIONS OFF)
66

7-
project(image-exporter)
7+
project(image-upscaler)
88

9-
add_executable(${PROJECT_NAME})
9+
option(IMAGE_UPSCALE_TEST "Build image upscale test" ON)
10+
11+
add_library(${PROJECT_NAME})
12+
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) # this is what other targets will link to
1013
target_include_directories(${PROJECT_NAME} PUBLIC ./include)
1114
target_sources(${PROJECT_NAME} PRIVATE
1215
include/image_upscaler/image_upscaler.hpp
1316
src/image_upscaler.cpp
14-
tests/main.cpp
15-
)
17+
)
18+
19+
if(IMAGE_UPSCALE_TEST)
20+
add_subdirectory(tests)
21+
endif()
1622

1723
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
1824
target_compile_options(${PROJECT_NAME} PRIVATE
1925
-Wall -Wextra -Wpedantic -Wconversion -Werror=return-type
20-
)
26+
)
2127
endif()

CMakePresets.json

100644100755
File mode changed.

README.md

100644100755
File mode changed.

include/image_upscaler/image_upscaler.hpp

100644100755
File mode changed.

src/image_upscaler.cpp

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <image_upscaler/image_upscaler.hpp>
77

88
/* Implementation of Rgba */
9-
Rgba::Rgba(uint32_t hex) : r((hex & 0xFF'00'00'00) >> 24), g((hex & 0x00'FF'00'00) >> 16), b((hex & 0x00'00'FF'00) >> 8), a(hex & 0x00'00'00'FF) {}
9+
Rgba::Rgba(uint32_t hex) : r(static_cast<uint8_t>((hex & 0xFF'00'00'00) >> 24)), g(static_cast<uint8_t>((hex & 0x00'FF'00'00) >> 16)), b(static_cast<uint8_t>((hex & 0x00'00'FF'00) >> 8)), a(static_cast<uint8_t>(hex & 0x00'00'00'FF)) {}
1010

1111
Rgba::Rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a) {}
1212

tests/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_executable(upscale-test)
2+
target_link_libraries(upscale-test PRIVATE image-upscaler::image-upscaler)
3+
target_sources(upscale-test PRIVATE main.cpp)
4+
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
5+
target_compile_options(upscale-test PRIVATE
6+
-Wall -Wextra -Wpedantic -Wconversion -Werror=return-type
7+
)
8+
9+
endif()

tests/main.cpp

100644100755
File mode changed.

0 commit comments

Comments
 (0)