Skip to content

Commit

Permalink
cmake: custom prefix support
Browse files Browse the repository at this point in the history
  • Loading branch information
wirx6 committed Feb 5, 2017
1 parent 9f9e17a commit c95e52f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
29 changes: 27 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,16 @@ execute_process(
OUTPUT_VARIABLE QT_INSTALL_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Qt version: ${Qt5Core_VERSION_STRING}")
execute_process(
COMMAND ${qmake} -query QT_INSTALL_BINS
OUTPUT_VARIABLE QT_INSTALL_BINS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${qmake} -query QT_INSTALL_PREFIX
OUTPUT_VARIABLE QT_INSTALL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT5_CFLAGS}")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand All @@ -32,12 41,28 @@ endif()
set(CMAKE_CXX_VISIBILITY_PRESET hidden) #use with -fdata-sections -ffunction-sections to reduce target size
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)


# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON) # for .moc
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${QT_INSTALL_PREFIX} CACHE PATH "default install path" FORCE)
set(QTAV_INSTALL_HEADERS ${QT_INSTALL_HEADERS} CACHE PATH "")
set(QTAV_INSTALL_LIBS ${QT_INSTALL_LIBS} CACHE PATH "")
set(QTAV_INSTALL_BINS ${QT_INSTALL_BINS} CACHE PATH "")
else()
set(QTAV_INSTALL_HEADERS ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "")
set(QTAV_INSTALL_LIBS ${CMAKE_INSTALL_PREFIX}/lib CACHE PATH "")
set(QTAV_INSTALL_BINS ${CMAKE_INSTALL_PREFIX}/bin CACHE PATH "")
endif()

message(STATUS "Qt version: ${Qt5Core_VERSION_STRING}")
message(STATUS "Qt prefix: ${QT_INSTALL_PREFIX}")
message(STATUS "QtAV headers prefix: ${QTAV_INSTALL_HEADERS}")
message(STATUS "QtAV libs prefix: ${QTAV_INSTALL_LIBS}")
message(STATUS "QtAV bins prefix: ${QTAV_INSTALL_BINS}")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
18 changes: 9 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,25 511,25 @@ target_compile_definitions(${MODULE} PRIVATE ${EXTRA_DEFS})

install(FILES
${SDK_HEADERS}
DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}
DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}
)
install(FILES
${SDK_PRIVATE_HEADERS}
DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}/private
DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}/private
)
install(TARGETS ${MODULE}
EXPORT ${MODULE}-targets
#PUBLIC_HEADER DESTINATION ${QT_INSTALL_HEADERS}/${MODULE} # list is too long
#PRIVATE_HEADER DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}/private
RUNTIME DESTINATION ${QT_INSTALL_LIBS}/bin
LIBRARY DESTINATION ${QT_INSTALL_LIBS}/lib
ARCHIVE DESTINATION ${QT_INSTALL_LIBS}/lib
FRAMEWORK DESTINATION ${QT_INSTALL_LIBS}
#PUBLIC_HEADER DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE} # list is too long
#PRIVATE_HEADER DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}/private
RUNTIME DESTINATION ${QTAV_INSTALL_BINS}
LIBRARY DESTINATION ${QTAV_INSTALL_LIBS}
ARCHIVE DESTINATION ${QTAV_INSTALL_LIBS}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
)

# FIXME: why QTAV_INCLUDE_DIRS is empty?
install(EXPORT ${MODULE}-targets
DESTINATION ${QT_INSTALL_LIBS}/cmake/${MODULE}
DESTINATION ${QTAV_INSTALL_LIBS}/cmake/${MODULE}
FILE ${MODULE}-config.cmake
)

18 changes: 9 additions & 9 deletions widgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 78,22 @@ target_compile_definitions(${MODULE} PRIVATE ${EXTRA_DEFS})

install(FILES
${SDK_HEADERS}
DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}
DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}
)
install(FILES
${SDK_PRIVATE_HEADERS}
DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}/private
DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}/private
)
install(TARGETS ${MODULE}
EXPORT ${MODULE}-targets
#PUBLIC_HEADER DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}
#PRIVATE_HEADER DESTINATION ${QT_INSTALL_HEADERS}/${MODULE}/private
RUNTIME DESTINATION ${QT_INSTALL_LIBS}/bin
LIBRARY DESTINATION ${QT_INSTALL_LIBS}/lib
ARCHIVE DESTINATION ${QT_INSTALL_LIBS}/lib
FRAMEWORK DESTINATION ${QT_INSTALL_LIBS}
#PUBLIC_HEADER DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}
#PRIVATE_HEADER DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}/private
RUNTIME DESTINATION ${QTAV_INSTALL_BINS}
LIBRARY DESTINATION ${QTAV_INSTALL_LIBS}
ARCHIVE DESTINATION ${QTAV_INSTALL_LIBS}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(EXPORT ${MODULE}-targets
DESTINATION ${QT_INSTALL_LIBS}/cmake/${MODULE}
DESTINATION ${QTAV_INSTALL_LIBS}/cmake/${MODULE}
FILE ${MODULE}-config.cmake
)

0 comments on commit c95e52f

Please sign in to comment.