Merge pull request 'Implement CMake to optimize cross-compilation support' (#1) from cmake-dev into master
Reviewed-on: #1 Work on unix
This commit is contained in:
commit
43d08752fa
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,6 +15,7 @@
|
|||||||
# Precompiled Headers
|
# Precompiled Headers
|
||||||
*.gch
|
*.gch
|
||||||
*.pch
|
*.pch
|
||||||
|
src/config.h
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
*.lib
|
*.lib
|
||||||
@ -41,7 +42,7 @@
|
|||||||
*.su
|
*.su
|
||||||
*.idb
|
*.idb
|
||||||
*.pdb
|
*.pdb
|
||||||
testfiles/
|
samples/
|
||||||
|
|
||||||
# Kernel Module Compile Results
|
# Kernel Module Compile Results
|
||||||
*.mod*
|
*.mod*
|
||||||
|
48
CMakeLists.txt
Normal file
48
CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# CMakeLists.txt
|
||||||
|
|
||||||
|
# Written by JackCarterSmith, 2020
|
||||||
|
# This code is released under the RSE license.
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
cmake_policy(VERSION 3.1)
|
||||||
|
|
||||||
|
# define project
|
||||||
|
project(rse-texture VERSION 1.0.1 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
set(RSE_TEX_NAME RSE_Texture-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY)
|
||||||
|
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
|
||||||
|
# needed packages
|
||||||
|
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
include_directories(${ZLIB_INCLUDE_DIR})
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
include_directories(${PNG_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# define src/headers files
|
||||||
|
|
||||||
|
FILE(GLOB RSE_TEX_SRCS src/*.c)
|
||||||
|
FILE(GLOB RSE_TEX_HRDS src/*.h)
|
||||||
|
SOURCE_GROUP("Source Files" FILES ${RSE_TEX_SRCS})
|
||||||
|
SOURCE_GROUP("Header Files" FILES ${RSE_TEX_HRDS})
|
||||||
|
|
||||||
|
# begin building RSE-Texture
|
||||||
|
|
||||||
|
#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
add_executable(rse-texture ${RSE_TEX_SRCS} ${RSE_TEX_HRDS})
|
||||||
|
set_target_properties(rse-texture PROPERTIES OUTPUT_NAME ${RSE_TEX_NAME})
|
||||||
|
if(MSVC)
|
||||||
|
# msvc does not append 'lib' - do it here to have consistent name
|
||||||
|
set_target_properties(rse-texture PROPERTIES PREFIX "lib")
|
||||||
|
set_target_properties(rse-texture PROPERTIES IMPORT_PREFIX "lib")
|
||||||
|
endif()
|
||||||
|
target_link_libraries(rse-texture ${ZLIB_LIBRARIES} ${PNG_LIBRARIES})
|
||||||
|
|
||||||
|
# install executable
|
||||||
|
|
||||||
|
install(TARGETS rse-texture
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
)
|
33
Makefile
33
Makefile
@ -1,33 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
#CFLAGS= -Wextra -Wall -O0 -g
|
|
||||||
CFLAGS= -Wall -O3
|
|
||||||
LDFLAGS= -lz -lpng
|
|
||||||
|
|
||||||
TARGET=RogueDE-texture
|
|
||||||
VERSION=1.0a
|
|
||||||
SRC_DIR=src
|
|
||||||
SRC= $(wildcard $(SRC_DIR)/*.c)
|
|
||||||
INCLUDES=-I$(SRC_DIR)
|
|
||||||
BUILD_DIR=obj
|
|
||||||
OBJS= $(subst src,$(BUILD_DIR),$(SRC:%.c=%.o))
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: $(BUILD_DIR) all clean
|
|
||||||
|
|
||||||
|
|
||||||
all: clean $(BUILD_DIR) $(TARGET)
|
|
||||||
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: src/%.c
|
|
||||||
$(CC) $(INCLUDES) -DVERSION='"$(VERSION)"' -c -o $@ $< $(CFLAGS)
|
|
||||||
|
|
||||||
$(BUILD_DIR):
|
|
||||||
@mkdir -p $(BUILD_DIR)
|
|
||||||
|
|
||||||
$(TARGET): $(OBJS)
|
|
||||||
$(CC) -o $@_$(VERSION) $^ $(LDFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -rf $(BUILD_DIR)
|
|
||||||
@rm -f RogueDE-*
|
|
@ -10,6 +10,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "config.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "HMT_Parser.h"
|
#include "HMT_Parser.h"
|
||||||
#include "RS_images.h"
|
#include "RS_images.h"
|
||||||
|
1
src/config.h.in
Normal file
1
src/config.h.in
Normal file
@ -0,0 +1 @@
|
|||||||
|
#define VERSION "@PROJECT_VERSION@"
|
Loading…
x
Reference in New Issue
Block a user