# Compute include directories
# TODO: http://www.cmake.org/Bug/view.php?id=11889 contains a better solution
get_property(gcc_include_dirs
- DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- PROPERTY INCLUDE_DIRECTORIES
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ PROPERTY INCLUDE_DIRECTORIES
)
set(gccxml_include_dirs "")
foreach(gcc_include_dir ${gcc_include_dirs})
- set(gccxml_include_dirs "${gccxml_include_dirs} -I${gcc_include_dir}")
+ set(gccxml_include_dirs "${gccxml_include_dirs} -I${gcc_include_dir}")
endforeach(gcc_include_dir ${gcc_include_dirs})
foreach(CMDGROUP ${ARGV})
message(STATUS "Processing libt2n command group ${CMDGROUP}")
# We are going to run each .cpp file through gccxml for the current CMDGROUP
- set(T2N_GCCXML_FILES "")
- set(T2N_GCCXML_COMMANDS "")
+ set(T2N_GCCXML_FILES "")
+ set(T2N_GCCXML_COMMANDS "")
foreach(T2NFILE ${${CMDGROUP}_GROUP})
get_filename_component(FILE_NAME ${T2NFILE} NAME)
- get_filename_component(FILE_EXT ${T2NFILE} EXT)
- if(NOT FILE_EXT STREQUAL ".cpp")
- message(FATAL_ERROR " Error: ${FILE_NAME} is not a .cpp file based on its filename extension!")
- endif()
+ # get_filename_component(FILE_EXT ${T2NFILE} EXT) <-- Doesn't work for filenames with multiple dots
+ string(REGEX MATCH "(\\.[^\\.]*)$" FILE_EXT ${T2NFILE})
+ if(NOT FILE_EXT STREQUAL ".cpp")
+ message(FATAL_ERROR " Error: ${FILE_NAME} is not a .cpp file based on its filename extension!")
+ endif()
message(STATUS " Processing file ${FILE_NAME}")
- # We build the commands in advance which execute gccxml on each file in the CMDGROUP
- set(T2N_GCCXML_COMMANDS ${T2N_GCCXML_COMMANDS}
- COMMAND ${LIBT2N_GCCXML} ${gccxml_include_dirs} ${T2NFILE} -fxml=${T2NFILE}.xml
- )
- # The filenames of the created intermediate gccxml files for the current CMDGROUP
- set(T2N_GCCXML_FILES ${T2N_GCCXML_FILES} ${T2NFILE}.xml)
+ # We build the commands in advance which execute gccxml on each file in the CMDGROUP
+ set(T2N_GCCXML_COMMANDS ${T2N_GCCXML_COMMANDS}
+ COMMAND ${LIBT2N_GCCXML} ${gccxml_include_dirs} ${T2NFILE} -fxml=${T2NFILE}.xml
+ )
+ # The filenames of the created intermediate gccxml files for the current CMDGROUP
+ set(T2N_GCCXML_FILES ${T2N_GCCXML_FILES} ${T2NFILE}.xml)
endforeach(T2NFILE ${${CMDGROUP}_GROUP})
- add_custom_command(
- OUTPUT ${CMDGROUP}_common.cpp ${CMDGROUP}_common.hxx ${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx ${CMDGROUP}_server.cpp ${CMDGROUP}_server.hxx
+ add_custom_command(
+ OUTPUT ${CMDGROUP}_common.cpp ${CMDGROUP}_common.hxx ${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx ${CMDGROUP}_server.cpp ${CMDGROUP}_server.hxx
- # Create dummy _common.hxx file
- COMMAND echo "\\#include \\\"codegen-stubhead.hxx\\\"" >${CMDGROUP}_common.hxx
- COMMAND echo "\\#include \\\"${CMDGROUP}.hxx\\\"" >>${CMDGROUP}_common.hxx
+ # Create dummy _common.hxx file
+ COMMAND echo "\\#include \\\"codegen-stubhead.hxx\\\"" >${CMDGROUP}_common.hxx
+ COMMAND echo "\\#include \\\"${CMDGROUP}.hxx\\\"" >>${CMDGROUP}_common.hxx
- # Invoke gccxml on each source file in the current CMDGROUP and delete the dummy file
- ${T2N_GCCXML_COMMANDS}
- COMMAND rm -f ${CMDGROUP}_common.hxx
+ # Invoke gccxml on each source file in the current CMDGROUP and delete the dummy file
+ ${T2N_GCCXML_COMMANDS}
+ COMMAND rm -f ${CMDGROUP}_common.hxx
- # Run the code generator on all the generated gccxml files and remove those intermediate gccxml files
- COMMAND ${LIBT2N_CODEGEN} ${CMDGROUP} ${T2N_GCCXML_FILES}
- COMMAND rm -f ${T2N_GCCXML_FILES}
+ # Run the code generator on all the generated gccxml files and remove those intermediate gccxml files
+ COMMAND ${LIBT2N_CODEGEN} ${CMDGROUP} ${T2N_GCCXML_FILES}
+ COMMAND rm -f ${T2N_GCCXML_FILES}
- DEPENDS ${${CMDGROUP}_GROUP}
- )
+ DEPENDS ${${CMDGROUP}_GROUP}
+ )
# Write out pkgconfig file
- configure_file(${LIBT2N_CLIENT_PCTEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/${CMDGROUP}.pc @ONLY@)
+ configure_file(${LIBT2N_CLIENT_PCTEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/${CMDGROUP}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMDGROUP}.pc
DESTINATION lib/pkgconfig)
# Create shared client library
add_library(${CMDGROUP} SHARED ${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx)
set_target_properties(${CMDGROUP} PROPERTIES VERSION ${VERSION} SOVERSION 1)
- target_link_libraries(${CMDGROUP} ${Boost_SERIALIZATION_LIBRARIES})
+ target_link_libraries(${CMDGROUP} ${Boost_SERIALIZATION_LIBRARIES})
install(TARGETS ${CMDGROUP} LIBRARY DESTINATION lib COMPONENT sharedlibs)
# Create static client library
add_library(${CMDGROUP}-static STATIC ${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx)
set_target_properties(${CMDGROUP}-static PROPERTIES OUTPUT_NAME "${CMDGROUP}")
- target_link_libraries(${CMDGROUP}-static ${Boost_SERIALIZATION_LIBRARIES})
+ target_link_libraries(${CMDGROUP}-static ${Boost_SERIALIZATION_LIBRARIES})
install(TARGETS ${CMDGROUP}-static ARCHIVE DESTINATION lib COMPONENT staticlibs)
# Prevent clobbering each other during the build
)
# Wait till generated code is available
- add_custom_target(${CMDGROUP}_codegen_done ALL DEPENDS ${CMDGROUP}_common.cpp ${CMDGROUP}_common.hxx ${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx ${CMDGROUP}_server.cpp ${CMDGROUP}_server.hxx)
+ add_custom_target(${CMDGROUP}_codegen_done ALL DEPENDS ${CMDGROUP}_common.cpp ${CMDGROUP}_common.hxx ${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx ${CMDGROUP}_server.cpp ${CMDGROUP}_server.hxx)
add_dependencies(${CMDGROUP} ${CMDGROUP}_codegen_done)
add_dependencies(${CMDGROUP}-static ${CMDGROUP}_codegen_done)