Skip to content

Commit 7576bf0

Browse files
committed
Made some improvements to the CMake package config file support.
1 parent 39e61d6 commit 7576bf0

File tree

4 files changed

+60
-12
lines changed

4 files changed

+60
-12
lines changed
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
@PACKAGE_INIT@
22

3-
set(JasPer_FOUND TRUE)
3+
INCLUDE(CMakeFindDependencyMacro)
44

5-
include("${CMAKE_CURRENT_LIST_DIR}/JasPerTargets.cmake")
5+
# Ensure that the JPEG::JPEG imported target is defined (if appropriate).
6+
IF(@JAS_INCLUDE_JPG_CODEC@)
7+
FIND_DEPENDENCY(JPEG)
8+
ENDIF()
9+
10+
# Mark the JasPer library as found.
11+
SET(JasPer_FOUND TRUE)
12+
13+
# Include the exported targets.
14+
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/JasPerTargets.cmake")

src/libjasper/CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,6 @@ add_library(libjasper ${libjasper_type}
168168
${libjasper_ras_sources}
169169
)
170170

171-
if(JAS_ENABLE_CMAKE_PACKAGE_CONFIG)
172-
install(TARGETS libjasper
173-
EXPORT JasPerTargets
174-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
175-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
176-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
177-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
178-
)
179-
endif()
180-
181171
# The JasPer include directories in the source and build tree must be included
182172
# before any other directories that may contain the include directory for an
183173
# already installed version of the JasPer library.
@@ -226,6 +216,17 @@ generate_export_header(libjasper
226216
NO_EXPORT_MACRO_NAME JAS_LOCAL
227217
)
228218

219+
if(JAS_ENABLE_CMAKE_PACKAGE_CONFIG)
220+
#install(TARGETS libjasper ${JAS_LIBJPEG_TARGET}
221+
install(TARGETS libjasper
222+
EXPORT JasPerTargets
223+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
224+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
225+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
226+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
227+
)
228+
endif()
229+
229230
install(TARGETS libjasper
230231
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
231232
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

test/src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
project(test_app LANGUAGES C)
4+
5+
find_package(JasPer CONFIG REQUIRED)
6+
7+
add_executable(app app.c)
8+
target_link_libraries(app JasPer::libjasper)
9+
10+
install(CODE "message(STATUS \"Dummy install target executed.\")")

test/src/app.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/******************************************************************************\
2+
* Includes.
3+
\******************************************************************************/
4+
5+
#include <stdlib.h>
6+
#include <stdio.h>
7+
8+
#include <jasper/jasper.h>
9+
10+
/******************************************************************************\
11+
* Some dummy code.
12+
\******************************************************************************/
13+
14+
int main(int argc, char **argv)
15+
{
16+
jas_conf_clear();
17+
if (jas_init_library()) {
18+
fprintf(stderr, "cannot initialize JasPer library\n");
19+
return EXIT_FAILURE;
20+
}
21+
if (jas_init_thread()) {
22+
fprintf(stderr, "cannot initialize thread\n");
23+
return EXIT_FAILURE;
24+
}
25+
jas_cleanup_thread();
26+
jas_cleanup_library();
27+
return 0;
28+
}

0 commit comments

Comments
 (0)