Skip to content

Commit

Permalink
cmake updated for nomacs
Browse files Browse the repository at this point in the history
- adds a cmake config
- adds userpaths
- different release/debug targets for windows
  • Loading branch information
diemmarkus committed Aug 1, 2019
1 parent 70f9405 commit c921770
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ test/tmp/*
doc/html

contrib/vms/.vagrant
CmakeUserPaths.cmake
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ project(exiv2
LANGUAGES CXX C
)

# load paths from the user file if exists
if (EXISTS ${CMAKE_SOURCE_DIR}/CMakeUserPaths.cmake)
include(${CMAKE_SOURCE_DIR}/CMakeUserPaths.cmake)
message(STATUS "using user paths...")
elseif(MSVC)
message(WARNING "Could not find CMakeUserPaths.cmake - please use this file to specify your install directories (see CMakeUserPathsGit.cmake)")
endif()

include(cmake/mainSetup.cmake REQUIRED)

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

include(cmake/printSummary.cmake)

# diem: create config
set(EXIV2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR})
set(EXIV2_LIBS optimized ${CMAKE_BINARY_DIR}/lib/Release/exiv2.lib debug ${CMAKE_BINARY_DIR}/lib/Debug/exiv2.lib)
set(EXIV2_BINARY_DIR ${CMAKE_BINARY_DIR}/src/)
set(EXPAT_BINARY_DIR optimized ${CMAKE_BINARY_DIR}/bin)
configure_file(${CMAKE_SOURCE_DIR}/exiv2.cmake.in ${CMAKE_BINARY_DIR}/exiv2Config.cmake)

message(STATUS "version: ${PROJECT_VERSION}")

# That's all Folks!
##
25 changes: 25 additions & 0 deletions CMakeUserPathsGit.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# If you want to use prefix paths with cmake, copy and rename this file to CMakeUserPaths.cmake
# Do not add this file to GIT!

IF (CMAKE_CL_64)

# we use opencv's zlib
SET(ZLIB_BUILD_PATH "C:/coding/3rd-party/opencv/build2017-x64/3rdparty")

# add the expat build
SET(EXPAT_BUILD_PATH "C:/coding/3rd-party/expat/build2017-x64/")
ELSE()

# we use opencv's zlib
SET(ZLIB_BUILD_PATH "C:/coding/3rd-party/opencv/build2017-x86/3rdparty")

# add the expat build
SET(EXPAT_BUILD_PATH "C:/coding/3rd-party/expat/build2017-x86/")
ENDIF()

SET(ZLIB_INCLUDE_DIR "C:/coding/3rd-party/opencv/3rdparty/zlib")
SET(ZLIB_LIBRARY_DEBUG "${ZLIB_BUILD_PATH}/lib/Debug/zlibd.lib")
SET(ZLIB_LIBRARY_RELEASE "${ZLIB_BUILD_PATH}/lib/Release/zlib.lib")

SET(EXPAT_INCLUDE_DIR "C:/coding/3rd-party/expat/lib")
SET(EXPAT_LIBRARY "${EXPAT_BUILD_PATH}/Release/expat.lib")
25 changes: 25 additions & 0 deletions README-nomacs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Building exiv2 for nomacs

## Build exiv2 (Windows)

### Compile dependencies

- [expat](https://github.com/nomacs/expat) (needed for exiv2)
- [OpenCV](https://github.com/TUWien/opencv) (>= 3.4) _optional_

### Compile Exiv2

- copy `CMakeUserPathsGit.cmake` and rename it to `CMakeUserPaths.cmake`
- add your library paths to the `${CMAKE_PREFIX_PATH}` in `CMakeUserPaths.cmake`
- Open CMake GUI
- set this folder to `where is the source code`
- choose a build folder (e.g. `build2019-x64`)
- Hit `Configure`then `Generate`
- Open the Project
- Compile the Solution (build Release and Debug)
- You should now have an `exiv2.dll` in $YOUR_EXIV2_BUILD_PATH$/bin
- In the `CMakeUserPaths.cmake` of your [nomacs](https://github.com/nomacs/nomacs) project, add this path:

```cmake
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "$EXIV2_PATH$/build2017-x64/")
```
13 changes: 10 additions & 3 deletions cmake/mainSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ include(CMakeDependentOption)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# diem: create debug/release outputs for windows
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/bin)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
endif()

if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand Down
15 changes: 15 additions & 0 deletions exiv2.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ** File generated automatically, do not modify **

SET(EXIV2_INCLUDE_DIRS @EXIV2_INCLUDE_DIRS@)
SET(EXIV2_LIBS @EXIV2_LIBS@)
SET(EXIV2_BUILD_PATH @CMAKE_CURRENT_BINARY_DIR@)
SET(EXIV2_PROJECT_NAME @PROJECT_NAME@)
SET(EXIV2_VERSION @PROJECT_VERSION@)

SET(EXPAT_BUILD_PATH @EXPAT_BUILD_PATH@)

IF(EXIV2_INCLUDE_DIRS)
SET(EXIV_FOUND true)
ELSE()
SET(EXIV_FOUND "EXIV_FOUND-NOTFOUND")
ENDIF()

0 comments on commit c921770

Please sign in to comment.