Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake support to the project #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.0)
project(img2tim LANGUAGES CXX)

find_library(freeimage_lib NAMES FreeImage freeimage)
find_path(freeimage_inc NAMES FreeImage.h freeimage.h)

if(freeimage_lib STREQUAL "freeimage_lib-NOTFOUND" OR
freeimage_inc STREQUAL "freeimage_inc-NOTFOUND")
message(FATAL_ERROR "Could not find FreeImage library on your system")
endif()

add_executable(img2tim tim.cpp main.cpp)
target_include_directories(img2tim PUBLIC "${freeimage_inc}" "${PROJECT_SOURCE_DIR}")
target_link_libraries(img2tim "${freeimage_lib}")
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ The latest precompiled Win32 binary of this program can be downloaded here:
Previous versions:
[img2tim_(v0.60).zip](http://lameguy64.github.io/img2tim/img2tim_(v0.60).zip)

## Building

You can build the `img2tim` binary executable using either _Code Blocks_ or _CMake_ right away as long as you have the _FreeImage_ library installed on your system (and, of course, either _Code Blocks_ or _CMake_ as well).

### Using Code Blocks

Open the already-provided `img2tim.cbp` file in _CodeBlocks_, assuming that the editor is already properly configured on your side: you should be able to build everything from there.

### Using CMake

Open a bash terminal, navigate to the root of the project and run the following command:
`mkdir -p build && cd build && cmake -S ..`
This will create a `build/` folder, then _CMake_ will generate the build files in it.
You will be notified in case of failure if, for example, the _FreeImage_ library could not be found.

Then, assuming the default _CMake_ generator was targeting _make_: just run `make` to build the program.
If it was targeting _ninja_ instead: run `ninja`.

At the end of it: the `img2tim` executable (with `.exe` extension on Windows) will be ready in the `build/` folder.

#### Custom CMake generator

You can select which generator you prefer by using the `-G` option with `cmake`, you can even generate a whole _Code Blocks_ project file from it, for example:
`cmake -G "CodeBlocks - Unix Makefiles" -B build` will produce a `img2tim.cbp` file in `build/`, which you can open with _Code Blocks_ (and it will use `make` behind the curtains to build the project).

To see the list of all available generators on your system: just run `cmake --help`.

## Changelog
**Version 0.75**
* Fixed a bug where a false error message is thrown when converting 4-bit images with -bpp 4.
Expand Down