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

View File

@ -30,7 +30,8 @@ list(APPEND LLVM_LIBS
LLVMBitReader LLVMBitReader
LLVMMC LLVMMC
LLVMSupport) 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) if(UNIX)
list(APPEND PLAT_LIBS z pthread curses dl) 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() 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) elseif(MSVC_VERSION EQUAL 1900)
list(APPEND extraargs -fms-compatibility-version=19.00) list(APPEND extraargs -fms-compatibility-version=19.00)
endif() endif()
# OSX Extra
elseif(APPLE)
list(APPEND extraargs -isysroot ${CMAKE_OSX_SYSROOT} -isysroot /)
endif() endif()
# Make target # Make target
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna> 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}") DEPENDS ${ins} COMMENT "Generating DNA ${out}")
endmacro() 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> 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::OptionCategory ATDNAFormatCategory("atdna options");
static llvm::cl::opt<std::string> OutputFilename("o", 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", static llvm::cl::list<std::string> SystemIncludeSearchPaths("isystem",
llvm::cl::desc("System Header search path")); 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", static llvm::cl::list<std::string> PreprocessorDefines("D",
llvm::cl::desc("Preprocessor define"), llvm::cl::desc("Preprocessor define"),
llvm::cl::Prefix); llvm::cl::Prefix);

View File

@ -81,5 +81,8 @@ if(WIN32 AND NOT UNIX)
install(DIRECTORY include/lzo DESTINATION include COMPONENT lzo2) install(DIRECTORY include/lzo DESTINATION include COMPONENT lzo2)
install(TARGETS lzo2 DESTINATION lib COMPONENT lzo2) install(TARGETS lzo2 DESTINATION lib COMPONENT lzo2)
endif() 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) 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() endif()

View File

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