Skip to content

Commit

Permalink
some CMake tuning for Xcode project generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Nov 9, 2013
1 parent f493412 commit 79b83f8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Doxyfile
cppa.creator.user*
html/
build/*
cli_build/*
build-clang/*
build-gcc/*
Makefile
Expand Down
44 changes: 27 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ endif ()

set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

# set binary output path
if ("${EXECUTABLE_OUTPUT_PATH}" STREQUAL "")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
endif ()

# set library output path
if ("${LIBRARY_OUTPUT_PATH}" STREQUAL "")
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
endif ()

# set library output path to binary output path for Xcode projects
if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
set(LIBRARY_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}")
endif ()

# check if the user provided CXXFLAGS on the command line
if (CMAKE_CXX_FLAGS)
set(CXXFLAGS_PROVIDED true)
Expand Down Expand Up @@ -92,6 +107,8 @@ else ()
message(FATAL_ERROR "This platform is not supported by libcppa")
endif()

# get header files; only needed by CMake generators,
# e.g., for creating proper Xcode projects
file(GLOB LIBCPPA_HDRS "cppa/*.hpp"
"cppa/detail/*.hpp"
"cppa/intrusive/*.hpp"
Expand All @@ -100,6 +117,7 @@ file(GLOB LIBCPPA_HDRS "cppa/*.hpp"
"cppa/qtsupport/*.hpp"
"cppa/util/*.hpp")

# list cpp files including platform-dependent files
set(LIBCPPA_SRC
${LIBCPPA_PLATFORM_SRC}
src/abstract_tuple.cpp
Expand Down Expand Up @@ -217,6 +235,7 @@ else (DISABLE_CONTEXT_SWITCHING)
find_package(Boost 1.51.0 COMPONENTS context)
# without REQUIRED, find_package(Boost...) returns with Boost_FOUND=FALSE
if (NOT Boost_FOUND)
# disable implicitly
set(DISABLE_CONTEXT_SWITCHING true)
else (NOT Boost_FOUND)
if (${Boost_VERSION} LESS 105400)
Expand All @@ -243,7 +262,7 @@ if (DISABLE_CONTEXT_SWITCHING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DISABLE_CONTEXT_SWITCHING")
endif ()

# bulid shared library only if not comiling static only
# bulid shared library if not comiling static only
if (NOT "${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_library(libcppa SHARED ${LIBCPPA_SRC} ${LIBCPPA_HDRS})
target_link_libraries(libcppa ${LD_FLAGS})
Expand All @@ -257,7 +276,7 @@ if (NOT "${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
install(TARGETS libcppa LIBRARY DESTINATION lib)
endif ()

# build static library if --build-static or --build-static-only was set
# build static library only if --build-static or --build-static-only was set
if ("${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes" OR "${CPPA_BUILD_STATIC}" STREQUAL "yes")
add_library(libcppaStatic STATIC ${LIBCPPA_HDRS} ${LIBCPPA_SRC})
set_target_properties(libcppaStatic PROPERTIES OUTPUT_NAME cppa_static)
Expand All @@ -280,15 +299,6 @@ add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

if (LIBRARY_OUTPUT_PATH)
set (CPPA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
set (CPPA_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH})
else ()
set (CPPA_LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
set (CPPA_LIBRARY_PATH ${CPPA_LIBRARY_OUTPUT_PATH})
set (LIBRARY_OUTPUT_PATH ${CPPA_LIBRARY_OUTPUT_PATH} CACHE PATH "Single directory for all libraries")
endif ()

# setting path to cppa headers and libcppa
set (CPPA_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcppa)
set (CPPA_INCLUDE ${CPPA_INCLUDE_PATH})
Expand All @@ -297,19 +307,19 @@ if ("${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa_static.a ${LD_FLAGS})
else ()
if (APPLE)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.dylib)
if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
set (CPPA_LIBRARY "-lcppa")
else ()
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.dylib)
endif ()
#set (CPPA_LIBRARY -L${LIBRARY_OUTPUT_PATH} -lcppa)
elseif (UNIX)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.so)
else ()
message (SEND_FATAL "Host platform not supported ...")
endif ()
endif ()

if (EXECUTABLE_OUTPUT_PATH)
else ()
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single directory for all executables")
endif ()

# set up subdirectories
if (NOT "${CPPA_NO_UNIT_TESTS}" STREQUAL "yes")
enable_testing()
Expand Down
6 changes: 3 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ configure ()
if [ -n "$2" ]; then
workdir="$builddir-$2"
else
workdir=$builddir
workdir="$builddir"
fi
workdirs="$workdirs $workdir"

if [ -n "$3" ]; then
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH $3
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH "$3"
else
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH "$workdir/bin"
fi

if [ -n "$4" ]; then
append_cache_entry LIBRARY_OUTPUT_PATH PATH $4
append_cache_entry LIBRARY_OUTPUT_PATH PATH "$4"
else
append_cache_entry LIBRARY_OUTPUT_PATH PATH "$workdir/lib"
fi
Expand Down

0 comments on commit 79b83f8

Please sign in to comment.