-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifies CMake files, with the objective of not modifying output dire…
…ctories. Now all files are copied after compilation. I also fiddle with the tests to make them more versatile.
- Loading branch information
Showing
7 changed files
with
104 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,46 @@ | ||
|
||
if(OJPH_BUILD_EXECUTABLES) | ||
|
||
# Add tiff library | ||
############################################################ | ||
if( OJPH_ENABLE_TIFF_SUPPORT ) | ||
|
||
if( MSVC ) | ||
|
||
set(TIFF_PATH "C:\\Program Files\\tiff") | ||
set(TIFF_INCLUDE_DIR "${TIFF_PATH}\\include" CACHE PATH "the directory containing the TIFF headers") | ||
set(TIFF_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") | ||
set(TIFF_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations") | ||
set(TIFFXX_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations") | ||
set(TIFFXX_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations") | ||
|
||
message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" ) | ||
message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " ) | ||
message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " ) | ||
message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " ) | ||
message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) | ||
message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) | ||
|
||
endif( MSVC ) | ||
|
||
FIND_PACKAGE( TIFF ) | ||
|
||
if( TIFF_FOUND ) | ||
set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") | ||
include_directories( ${TIFF_INCLUDE_DIR} ) | ||
add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT) | ||
endif( TIFF_FOUND ) | ||
|
||
endif() | ||
############################################################ | ||
|
||
## change folders but only for Microsoft | ||
if(MSVC) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../lib) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../lib) | ||
endif() | ||
|
||
## Build executables | ||
add_subdirectory(ojph_expand) | ||
add_subdirectory(ojph_compress) | ||
|
||
if (MSVC AND OJPH_ENABLE_TIFF_SUPPORT) | ||
if (CMAKE_BUILD_TYPE MATCHES "Release") | ||
file(COPY "${TIFF_PATH}\\bin\\tiff.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") | ||
file(COPY "${TIFF_PATH}\\bin\\tiffxx.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") | ||
elseif(CMAKE_BUILD_TYPE MATCHES "Debug") | ||
file(COPY "${TIFF_PATH}\\bin\\tiffd.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") | ||
file(COPY "${TIFF_PATH}\\bin\\tiffxxd.dll" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") | ||
endif() | ||
# Add tiff library | ||
############################################################ | ||
if( OJPH_ENABLE_TIFF_SUPPORT ) | ||
|
||
if( MSVC ) | ||
|
||
set(TIFF_INCLUDE_DIR "${TIFF_PATH}\\include" CACHE PATH "the directory containing the TIFF headers") | ||
set(TIFF_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffd.lib" CACHE FILEPATH "the path to the TIFF library for debug configurations") | ||
set(TIFF_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiff.lib" CACHE FILEPATH "the path to the TIFF library for release configurations") | ||
set(TIFFXX_LIBRARY_DEBUG "${TIFF_PATH}\\lib\\tiffxxd.lib" CACHE FILEPATH "the path to the TIFFXX library for debug configurations") | ||
set(TIFFXX_LIBRARY_RELEASE "${TIFF_PATH}\\lib\\tiffxx.lib" CACHE FILEPATH "the path to the TIFFXX library for release configurations") | ||
|
||
message( STATUS "WIN32 detected: Setting CMakeCache TIFF values as follows, use CMake-gui Advanced to modify them" ) | ||
message( STATUS " TIFF_INCLUDE_DIR : \"${TIFF_INCLUDE_DIR}\" " ) | ||
message( STATUS " TIFF_LIBRARY_DEBUG : \"${TIFF_LIBRARY_DEBUG}\" " ) | ||
message( STATUS " TIFF_LIBRARY_RELEASE : \"${TIFF_LIBRARY_RELEASE}\" " ) | ||
message( STATUS " TIFFXX_LIBRARY_DEBUG : \"${TIFFXX_LIBRARY_DEBUG}\" " ) | ||
message( STATUS " TIFFXX_LIBRARY_RELEASE : \"${TIFFXX_LIBRARY_RELEASE}\" " ) | ||
|
||
endif( MSVC ) | ||
|
||
FIND_PACKAGE( TIFF ) | ||
|
||
if( TIFF_FOUND ) | ||
set(USE_TIFF TRUE CACHE BOOL "Add TIFF support") | ||
include_directories( ${TIFF_INCLUDE_DIR} ) | ||
add_definitions(-DOJPH_ENABLE_TIFF_SUPPORT) | ||
endif( TIFF_FOUND ) | ||
|
||
endif() | ||
############################################################ | ||
|
||
## Build executables | ||
add_subdirectory(ojph_expand) | ||
add_subdirectory(ojph_compress) | ||
|
||
if (MSVC AND OJPH_ENABLE_TIFF_SUPPORT) | ||
if (CMAKE_BUILD_TYPE MATCHES "Release") | ||
file(COPY "${TIFF_PATH}\\bin\\tiff.dll" DESTINATION "${OJPH_DESTINATION_BINARY}") | ||
file(COPY "${TIFF_PATH}\\bin\\tiffxx.dll" DESTINATION "${OJPH_DESTINATION_BINARY}") | ||
elseif(CMAKE_BUILD_TYPE MATCHES "Debug") | ||
file(COPY "${TIFF_PATH}\\bin\\tiffd.dll" DESTINATION "${OJPH_DESTINATION_BINARY}") | ||
file(COPY "${TIFF_PATH}\\bin\\tiffxxd.dll" DESTINATION "${OJPH_DESTINATION_BINARY}") | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4d50eb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the regular CMake
install
command instead of explicitly copying, and please remove the hard-codedOJPH_DESTINATION_{BINARY,ARCHIVE}
variables. Thank you.4d50eb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been done in version 0.10.5.
I find these requirements very restrictive.
4d50eb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why that would be, and these are not strictly Linux-centric. There are a plethora of cross-platform libraries out there you can study that are just fine w/ CMake best practices and don't need all this special casing for MSVC...
Edit: For example, instead of hard coding and special casing all the TIFF stuff for MSVC, you'd pass
-DCMAKE_PREFIX_PATH=C:\Program Files\tiff
when you runcmake
(as this is specific to your machine, not MSVC necessarily), and then all the rest works the same on all platforms. CMake is smart enough to look into include, lib, pick debug version if required, etc.But you're the owner and it's ultimately your prerogative how you want to proceed.
4d50eb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, you can have your own
CMAKE_PREFIX_PATH
environment variable with not just path to tiff, but any other Windows locally installed libraries as well.Note that if you use a more integrated development environment on Windows like vcpkg, it takes care of all of this automatically. (So does MSYS2 + MinGW, but it doesn't use MSVC like vcpkg does.)
4d50eb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Milos,
Thank you for the feedback. You know way more than I do about CMake.
CMake is a large package with a lot to learn.
CMAKE_PREFIX_PATH seems to be a magic variable that helps with a lot of things.
I will see how to incorporate it in the next release.
Kind regards,
Aous.