Skip to content

Commit c921770

Browse files
committed
cmake updated for nomacs
- adds a cmake config - adds userpaths - different release/debug targets for windows
1 parent 70f9405 commit c921770

File tree

6 files changed

+93
-3
lines changed

6 files changed

+93
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ test/tmp/*
1818
doc/html
1919

2020
contrib/vms/.vagrant
21+
CmakeUserPaths.cmake

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ project(exiv2
55
LANGUAGES CXX C
66
)
77

8+
# load paths from the user file if exists
9+
if (EXISTS ${CMAKE_SOURCE_DIR}/CMakeUserPaths.cmake)
10+
include(${CMAKE_SOURCE_DIR}/CMakeUserPaths.cmake)
11+
message(STATUS "using user paths...")
12+
elseif(MSVC)
13+
message(WARNING "Could not find CMakeUserPaths.cmake - please use this file to specify your install directories (see CMakeUserPathsGit.cmake)")
14+
endif()
15+
816
include(cmake/mainSetup.cmake REQUIRED)
917

1018
# options and their default values
@@ -107,5 +115,14 @@ install(FILES ${CMAKE_BINARY_DIR}/exiv2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/p
107115

108116
include(cmake/printSummary.cmake)
109117

118+
# diem: create config
119+
set(EXIV2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR})
120+
set(EXIV2_LIBS optimized ${CMAKE_BINARY_DIR}/lib/Release/exiv2.lib debug ${CMAKE_BINARY_DIR}/lib/Debug/exiv2.lib)
121+
set(EXIV2_BINARY_DIR ${CMAKE_BINARY_DIR}/src/)
122+
set(EXPAT_BINARY_DIR optimized ${CMAKE_BINARY_DIR}/bin)
123+
configure_file(${CMAKE_SOURCE_DIR}/exiv2.cmake.in ${CMAKE_BINARY_DIR}/exiv2Config.cmake)
124+
125+
message(STATUS "version: ${PROJECT_VERSION}")
126+
110127
# That's all Folks!
111128
##

CMakeUserPathsGit.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# If you want to use prefix paths with cmake, copy and rename this file to CMakeUserPaths.cmake
2+
# Do not add this file to GIT!
3+
4+
IF (CMAKE_CL_64)
5+
6+
# we use opencv's zlib
7+
SET(ZLIB_BUILD_PATH "C:/coding/3rd-party/opencv/build2017-x64/3rdparty")
8+
9+
# add the expat build
10+
SET(EXPAT_BUILD_PATH "C:/coding/3rd-party/expat/build2017-x64/")
11+
ELSE()
12+
13+
# we use opencv's zlib
14+
SET(ZLIB_BUILD_PATH "C:/coding/3rd-party/opencv/build2017-x86/3rdparty")
15+
16+
# add the expat build
17+
SET(EXPAT_BUILD_PATH "C:/coding/3rd-party/expat/build2017-x86/")
18+
ENDIF()
19+
20+
SET(ZLIB_INCLUDE_DIR "C:/coding/3rd-party/opencv/3rdparty/zlib")
21+
SET(ZLIB_LIBRARY_DEBUG "${ZLIB_BUILD_PATH}/lib/Debug/zlibd.lib")
22+
SET(ZLIB_LIBRARY_RELEASE "${ZLIB_BUILD_PATH}/lib/Release/zlib.lib")
23+
24+
SET(EXPAT_INCLUDE_DIR "C:/coding/3rd-party/expat/lib")
25+
SET(EXPAT_LIBRARY "${EXPAT_BUILD_PATH}/Release/expat.lib")

README-nomacs.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Building exiv2 for nomacs
2+
3+
## Build exiv2 (Windows)
4+
5+
### Compile dependencies
6+
7+
- [expat](https://github.com/nomacs/expat) (needed for exiv2)
8+
- [OpenCV](https://github.com/TUWien/opencv) (>= 3.4) _optional_
9+
10+
### Compile Exiv2
11+
12+
- copy `CMakeUserPathsGit.cmake` and rename it to `CMakeUserPaths.cmake`
13+
- add your library paths to the `${CMAKE_PREFIX_PATH}` in `CMakeUserPaths.cmake`
14+
- Open CMake GUI
15+
- set this folder to `where is the source code`
16+
- choose a build folder (e.g. `build2019-x64`)
17+
- Hit `Configure`then `Generate`
18+
- Open the Project
19+
- Compile the Solution (build Release and Debug)
20+
- You should now have an `exiv2.dll` in $YOUR_EXIV2_BUILD_PATH$/bin
21+
- In the `CMakeUserPaths.cmake` of your [nomacs](https://github.com/nomacs/nomacs) project, add this path:
22+
23+
```cmake
24+
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "$EXIV2_PATH$/build2017-x64/")
25+
```

cmake/mainSetup.cmake

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ include(CMakeDependentOption)
99
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1010
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1111

12-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
13-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
14-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
12+
# diem: create debug/release outputs for windows
13+
if (MSVC)
14+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
15+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/bin)
16+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/bin)
17+
else()
18+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
19+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
20+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
21+
endif()
1522

1623
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
1724
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

exiv2.cmake.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ** File generated automatically, do not modify **
2+
3+
SET(EXIV2_INCLUDE_DIRS @EXIV2_INCLUDE_DIRS@)
4+
SET(EXIV2_LIBS @EXIV2_LIBS@)
5+
SET(EXIV2_BUILD_PATH @CMAKE_CURRENT_BINARY_DIR@)
6+
SET(EXIV2_PROJECT_NAME @PROJECT_NAME@)
7+
SET(EXIV2_VERSION @PROJECT_VERSION@)
8+
9+
SET(EXPAT_BUILD_PATH @EXPAT_BUILD_PATH@)
10+
11+
IF(EXIV2_INCLUDE_DIRS)
12+
SET(EXIV_FOUND true)
13+
ELSE()
14+
SET(EXIV_FOUND "EXIV_FOUND-NOTFOUND")
15+
ENDIF()

0 commit comments

Comments
 (0)