OS X support for atdna macro; dependency resolution fix

This commit is contained in:
Jack Andersen 2015-09-02 08:49:23 -10:00
parent 4a4962424d
commit a16fd79838
6 changed files with 78 additions and 8 deletions

View File

@ -1,5 +1,7 @@
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
cmake_minimum_required(VERSION 3.0)
project(Athena)
endif()
##################
# Athena Version #
@ -73,7 +75,7 @@ add_library(AthenaCore
include/utf8proc.h
)
add_library(AthenaSakura
add_library(AthenaSakura EXCLUDE_FROM_ALL
src/Athena/Sprite.cpp
src/Athena/SpriteFile.cpp
src/Athena/SpriteFileReader.cpp
@ -89,7 +91,7 @@ add_library(AthenaSakura
include/Athena/SpritePart.hpp
)
add_library(AthenaWiiSave
add_library(AthenaWiiSave EXCLUDE_FROM_ALL
src/Athena/WiiBanner.cpp
src/Athena/WiiFile.cpp
src/Athena/WiiImage.cpp
@ -118,7 +120,7 @@ if(NOT MSVC)
set_source_files_properties(src/aes.cpp PROPERTIES COMPILE_FLAGS -maes)
endif()
add_library(AthenaZelda
add_library(AthenaZelda EXCLUDE_FROM_ALL
src/Athena/ALTTPFile.cpp
src/Athena/ALTTPFileReader.cpp
src/Athena/ALTTPFileWriter.cpp
@ -174,7 +176,7 @@ endforeach()
# Define installs
install(DIRECTORY include/ DESTINATION ${INSTALL_INCLUDE_DIR}/Athena COMPONENT Athena)
install(TARGETS AthenaCore AthenaSakura AthenaWiiSave AthenaZelda
install(TARGETS AthenaCore
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT Athena)
if(WIN32 AND NOT CYGWIN)
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT Athena)
@ -190,7 +192,7 @@ endif()
##################
# Add all targets to the build-tree export set
export(TARGETS AthenaCore AthenaSakura AthenaWiiSave AthenaZelda
export(TARGETS AthenaCore
FILE "${PROJECT_BINARY_DIR}/AthenaTargets.cmake")
# Export the package for use from the build-tree

View File

@ -30,7 +30,8 @@ list(APPEND LLVM_LIBS
LLVMBitReader
LLVMMC
LLVMSupport)
set(CLANG_INCLUDE_DIR ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_STRING}/include)
set(CLANG_INCLUDE_DIR ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_STRING}/include
CACHE PATH "Clang include dir" FORCE)
if(UNIX)
list(APPEND PLAT_LIBS z pthread curses dl)
@ -123,3 +124,50 @@ add_test(NAME test-dna COMMAND $<TARGET_FILE:atdna> -o test.cpp
endif()
#######################
# In-tree atdna macro #
#######################
# Super handy macro for adding atdna target
macro(atdna out)
# Make input files source-relative
set(ins "")
foreach(arg ${ARGN})
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
endforeach()
# Get local include directories for atdna
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
set(inccli "")
foreach(dir ${incdirs})
list(APPEND inccli "-I${dir}")
endforeach()
# Get local defines for atdna
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
set(cdefcli "")
foreach(def ${cdefs})
list(APPEND cdefcli "-D${def}")
endforeach()
# MS extra
unset(extraargs)
if(MSVC)
list(APPEND extraargs -fms-compatibility -fexceptions)
if(MSVC_VERSION EQUAL 1800)
list(APPEND extraargs -fms-compatibility-version=18.00)
elseif(MSVC_VERSION EQUAL 1900)
list(APPEND extraargs -fms-compatibility-version=19.00)
endif()
# OSX Extra
elseif(APPLE)
list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot /)
endif()
# Make target
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
ARGS ${extraargs} -o ${out} ${cdefcli} ${inccli} "-I${ATHENA_INCLUDE_DIR}"
-isystem "${CLANG_INCLUDE_DIR}" ${ins}
DEPENDS ${ins} COMMENT "Generating DNA ${out}")
endmacro()

View File

@ -42,11 +42,16 @@ macro(atdna out)
elseif(MSVC_VERSION EQUAL 1900)
list(APPEND extraargs -fms-compatibility-version=19.00)
endif()
# OSX Extra
elseif(APPLE)
list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot /)
endif()
# Make target
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
ARGS ${extraargs} -o ${out} ${cdefcli} ${inccli} "-I${ATHENA_INCLUDE_DIR}" -isystem "@CONF_CLANG_INCLUDE_DIR@" ${ins}
ARGS ${extraargs} -o ${out} ${cdefcli} ${inccli} "-I${ATHENA_INCLUDE_DIR}"
-isystem "@CONF_CLANG_INCLUDE_DIR@" ${ins}
DEPENDS ${ins} COMMENT "Generating DNA ${out}")
endmacro()

View File

@ -29,6 +29,8 @@ static unsigned AthenaError = 0;
static llvm::cl::opt<bool> Help("h", llvm::cl::desc("Alias for -help"), llvm::cl::Hidden);
static llvm::cl::opt<bool> Verbose("v", llvm::cl::desc("verbose mode"));
static llvm::cl::OptionCategory ATDNAFormatCategory("atdna options");
static llvm::cl::opt<std::string> OutputFilename("o",
@ -54,6 +56,12 @@ static llvm::cl::list<std::string> IncludeSearchPaths("I",
static llvm::cl::list<std::string> SystemIncludeSearchPaths("isystem",
llvm::cl::desc("System Header search path"));
static llvm::cl::opt<std::string> StandardCXXLib("stdlib",
llvm::cl::desc("Standard C++ library"));
static llvm::cl::list<std::string> SystemIncRoot("isysroot",
llvm::cl::desc("System include root"));
static llvm::cl::list<std::string> PreprocessorDefines("D",
llvm::cl::desc("Preprocessor define"),
llvm::cl::Prefix);

View File

@ -81,5 +81,8 @@ if(WIN32 AND NOT UNIX)
install(DIRECTORY include/lzo DESTINATION include COMPONENT lzo2)
install(TARGETS lzo2 DESTINATION lib COMPONENT lzo2)
endif()
set(LZO_LIB lzo2 CACHE PATH "LZO library" FORCE)
set(LZO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "LZO include path" FORCE)
else()
find_path(LZO_INCLUDE_DIR lzo/lzo1x.h)
endif()

View File

@ -30,5 +30,9 @@ if(WIN32 AND NOT UNIX)
install(FILES zconf.h zlib.h DESTINATION include COMPONENT zlib)
install(TARGETS z DESTINATION lib COMPONENT zlib)
endif()
set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE)
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE)
else()
set(ZLIB_LIBRARIES ${ZLIB_LIBRARIES} CACHE PATH "Zlib libraries" FORCE)
find_path(ZLIB_INCLUDE_DIR zlib.h)
endif()