Skip to content

Commit

Permalink
CMake use explicit source file specifying
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Jan 11, 2015
1 parent 384a48f commit ee3a998
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 131 deletions.
134 changes: 3 additions & 131 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,7 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLMMS_DEBUG")
# people simply updating git will still have this and mess up build with it
FILE(REMOVE include/lmmsconfig.h)

FILE(GLOB lmms_INCLUDES "${CMAKE_SOURCE_DIR}/include/*.h")
FILE(GLOB lmms_UI "${CMAKE_SOURCE_DIR}/src/gui/dialogs/*.ui" "${CMAKE_SOURCE_DIR}/src/gui/Forms/*.ui")
FILE(GLOB_RECURSE lmms_SOURCES "${CMAKE_SOURCE_DIR}/src/*.cpp")

SET(lmms_MOC ${lmms_INCLUDES})
FILE(GLOB LMMS_INCLUDES "${CMAKE_SOURCE_DIR}/include/*.h")

# Get list of all committers from git history, ordered by number of commits
FIND_PACKAGE(Git)
Expand All @@ -405,14 +401,6 @@ ENDIF(GIT_FOUND)

SET(lmms_EMBEDDED_RESOURCES "${CMAKE_SOURCE_DIR}/AUTHORS" "${CMAKE_SOURCE_DIR}/COPYING" "${CONTRIBUTORS}")

IF(QT5)
QT5_WRAP_CPP(lmms_MOC_out ${lmms_MOC} OPTIONS -nw -I${CMAKE_BINARY_DIR})
QT5_WRAP_UI(lmms_UI_out ${lmms_UI})
ELSE()
QT4_WRAP_CPP(lmms_MOC_out ${lmms_MOC} OPTIONS -nw -I${CMAKE_BINARY_DIR})
QT4_WRAP_UI(lmms_UI_out ${lmms_UI})
ENDIF()

# embedded resources stuff
IF(WIN32 OR WIN64)
# compile buildtools native
Expand Down Expand Up @@ -462,126 +450,14 @@ SET(MACOSX_BUNDLE_PROJECT_URL "http://lmms.io")
ADD_SUBDIRECTORY(plugins)
ADD_SUBDIRECTORY(data)
ADD_SUBDIRECTORY(doc)

# Enable C++11
ADD_DEFINITIONS("-std=c++0x")

#
# build LMMS-binary
#
IF(LMMS_BUILD_WIN32)
SET(EXTRA_LIBRARIES "-lwinmm")
ENDIF()

# Paths relative to lmms executable
FILE(RELATIVE_PATH LIB_DIR_RELATIVE "/${BIN_DIR}" "/${LIB_DIR}")
FILE(RELATIVE_PATH PLUGIN_DIR_RELATIVE "/${BIN_DIR}" "/${PLUGIN_DIR}")
ADD_DEFINITIONS(-D'LIB_DIR="${LIB_DIR_RELATIVE}/"' -D'PLUGIN_DIR="${PLUGIN_DIR_RELATIVE}/"' ${PULSEAUDIO_DEFINITIONS} ${PORTAUDIO_DEFINITIONS})
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/include"
${JACK_INCLUDE_DIRS}
${SAMPLERATE_INCLUDE_DIRS}
${SNDFILE_INCLUDE_DIRS})

IF(NOT ("${SDL_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${SDL_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${PORTAUDIO_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${PORTAUDIO_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${PULSEAUDIO_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${OGGVORBIS_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${OGGVORBIS_INCLUDE_DIR}")
ENDIF()
ADD_SUBDIRECTORY(src)

ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/lmms.1.gz" COMMAND gzip -c "\"${CMAKE_SOURCE_DIR}/lmms.1\"" > "\"${CMAKE_BINARY_DIR}/lmms.1.gz\"" DEPENDS "${CMAKE_SOURCE_DIR}/lmms.1" COMMENT "Generating lmms.1.gz")
ADD_EXECUTABLE(lmms ${lmms_SOURCES} ${lmms_INCLUDES} ${lmms_MOC_out} "${LMMS_ER_H}" ${lmms_UI_out} lmmsconfig.h lmmsversion.h "${WINRC}" "${CMAKE_BINARY_DIR}/lmms.1.gz")

TARGET_LINK_LIBRARIES(lmms ${CMAKE_THREAD_LIBS_INIT} ${QT_LIBRARIES} ${ASOUND_LIBRARY} ${SDL_LIBRARY} ${PORTAUDIO_LIBRARIES} ${PULSEAUDIO_LIBRARIES} ${JACK_LIBRARIES} ${OGGVORBIS_LIBRARIES} ${SAMPLERATE_LIBRARIES} ${SNDFILE_LIBRARIES} ${EXTRA_LIBRARIES})

IF(QT5)
TARGET_LINK_LIBRARIES(lmms Qt5::Widgets Qt5::Xml)
ENDIF()

IF(LMMS_BUILD_WIN32)

SET_TARGET_PROPERTIES(lmms PROPERTIES LINK_FLAGS "${LINK_FLAGS} -mwindows")
ADD_CUSTOM_COMMAND(TARGET lmms POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_BINARY_DIR}/lmms.exe\"")

INSTALL(TARGETS lmms RUNTIME DESTINATION "${BIN_DIR}")
INSTALL(FILES
"${MINGW_PREFIX}/bin/QtCore4.dll"
"${MINGW_PREFIX}/bin/QtGui4.dll"
"${MINGW_PREFIX}/bin/QtSvg4.dll"
"${MINGW_PREFIX}/bin/QtXml4.dll"
"${MINGW_PREFIX}/bin/libsamplerate-0.dll"
"${MINGW_PREFIX}/bin/libsndfile-1.dll"
"${MINGW_PREFIX}/bin/libvorbis-0.dll"
"${MINGW_PREFIX}/bin/libvorbisenc-2.dll"
"${MINGW_PREFIX}/bin/libvorbisfile-3.dll"
"${MINGW_PREFIX}/bin/libjpeg-9.dll"
"${MINGW_PREFIX}/bin/libogg-0.dll"
"${MINGW_PREFIX}/lib/libfltk.dll"
"${MINGW_PREFIX}/bin/libfluidsynth.dll"
"${MINGW_PREFIX}/bin/libfftw3f-3.dll"
"${MINGW_PREFIX}/bin/libFLAC-8.dll"
"${MINGW_PREFIX}/bin/libportaudio-2.dll"
"${MINGW_PREFIX}/bin/libpng16-16.dll"
"${MINGW_PREFIX}/bin/SDL.dll"
"${MINGW_PREFIX}/bin/libglib-2.0-0.dll"
"${MINGW_PREFIX}/bin/libgthread-2.0-0.dll"
"${MINGW_PREFIX}/bin/zlib1.dll"
"${MINGW_PREFIX}/${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32/bin/libwinpthread-1.dll"
DESTINATION .)

ELSE(LMMS_BUILD_WIN32)
IF(NOT LMMS_BUILD_APPLE)
SET_TARGET_PROPERTIES(lmms PROPERTIES LINK_FLAGS "${LINK_FLAGS} -Wl,-E")
ENDIF(NOT LMMS_BUILD_APPLE)

INSTALL(TARGETS lmms RUNTIME DESTINATION "${BIN_DIR}")
INSTALL(FILES "${CMAKE_BINARY_DIR}/lmms.1.gz" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1/" PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)

ENDIF(LMMS_BUILD_WIN32)

#
# rules for building localizations
#
FILE(GLOB lmms_LOCALES data/locale/*.ts)
SET(ts_targets "")
SET(qm_targets "")
FOREACH(_ts_file ${lmms_LOCALES})
STRING(REPLACE "${CMAKE_SOURCE_DIR}/data/locale/" "" _ts_target "${_ts_file}")
STRING(REPLACE ".ts" ".qm" _qm_file "${_ts_file}")
STRING(REPLACE ".ts" ".qm" _qm_target "${_ts_target}")
ADD_CUSTOM_TARGET(${_ts_target} COMMAND "${QT_LUPDATE_EXECUTABLE}" -locations none -no-obsolete -I ${CMAKE_SOURCE_DIR}/include/ ${lmms_SOURCES} ${lmms_INCLUDES} ${lmms_UI} `find "\"${CMAKE_SOURCE_DIR}/plugins/\"" -type f -name '*.cpp' -or -name '*.h'` -ts "\"${_ts_file}\"")
ADD_CUSTOM_TARGET(${_qm_target} COMMAND "${QT_LRELEASE_EXECUTABLE}" "\"${_ts_file}\"" -qm "\"${_qm_file}\"")
LIST(APPEND ts_targets "${_ts_target}")
LIST(APPEND qm_targets "${_qm_target}")
ENDFOREACH(_ts_file ${lmms_LOCALES})

ADD_CUSTOM_TARGET(update-locales)
FOREACH(_item ${ts_targets})
ADD_DEPENDENCIES(update-locales "${_item}")
ENDFOREACH(_item ${ts_targets})

ADD_CUSTOM_TARGET(finalize-locales ALL)
FOREACH(_item ${qm_targets})
ADD_DEPENDENCIES(finalize-locales "${_item}")
ENDFOREACH(_item ${qm_targets})


# install headers

IF(LMMS_BUILD_LINUX)
INSTALL(FILES ${lmms_INCLUDES}
INSTALL(FILES ${LMMS_INCLUDES}
"${CMAKE_BINARY_DIR}/lmmsconfig.h"
"${CMAKE_BINARY_DIR}/lmmsversion.h"
"${CMAKE_SOURCE_DIR}/src/gui/embed.cpp"
Expand Down Expand Up @@ -620,10 +496,6 @@ ADD_CUSTOM_TARGET(dist
COMMAND tar cjf lmms-${VERSION}-src.tar.bz2 "${TMP}"
COMMAND rm -rf "${TMP}")


SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LMMS_ER_H} ${lmms_MOC_out} ${lmms_UI_out} lmmsconfig.h lmms.1.gz")


#
# display configuration information
#
Expand Down
152 changes: 152 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
SET(LMMS_SRCS "")
SET(LMMS_UIS "")

SET(CMAKE_AUTOMOC ON)
#SET(CMAKE_AUTOMOC_MOC_OPTIONS -I${CMAKE_BINARY_DIR})

ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(tracks)

IF(QT5)
#QT5_WRAP_UI(LMMS_UI_OUT ${LMMS_UIS})
ELSE()
#QT4_WRAP_CPP(LMMS_MOC_OUT ${LMMS_INCLUDES} OPTIONS -nw -I${CMAKE_BINARY_DIR})
#QT4_WRAP_UI(LMMS_UI_OUT ${LMMS_UIS})
ENDIF()

# Paths relative to lmms executable
FILE(RELATIVE_PATH LIB_DIR_RELATIVE "/${BIN_DIR}" "/${LIB_DIR}")
FILE(RELATIVE_PATH PLUGIN_DIR_RELATIVE "/${BIN_DIR}" "/${PLUGIN_DIR}")
ADD_DEFINITIONS(-D'LIB_DIR="${LIB_DIR_RELATIVE}/"' -D'PLUGIN_DIR="${PLUGIN_DIR_RELATIVE}/"' ${PULSEAUDIO_DEFINITIONS} ${PORTAUDIO_DEFINITIONS})
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/include"
${JACK_INCLUDE_DIRS}
${SAMPLERATE_INCLUDE_DIRS}
${SNDFILE_INCLUDE_DIRS})

IF(NOT ("${SDL_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${SDL_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${PORTAUDIO_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${PORTAUDIO_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${PULSEAUDIO_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${OGGVORBIS_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${OGGVORBIS_INCLUDE_DIR}")
ENDIF()

# Enable C++11
ADD_DEFINITIONS("-std=c++0x")

ADD_EXECUTABLE(lmms
${LMMS_SRCS}
${LMMS_INCLUDES}
${LMMS_UI_OUT}
${LMMS_MOC_OUT}
"${WINRC}"
)

#SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LMMS_ER_H} ${LMMS_UI_out} lmmsconfig.h lmms.1.gz")

IF(LMMS_BUILD_WIN32)
SET(EXTRA_LIBRARIES "-lwinmm")
ENDIF()

TARGET_LINK_LIBRARIES(lmms
${CMAKE_THREAD_LIBS_INIT}
${QT_LIBRARIES}
${ASOUND_LIBRARY}
${SDL_LIBRARY}
${PORTAUDIO_LIBRARIES}
${PULSEAUDIO_LIBRARIES}
${JACK_LIBRARIES}
${OGGVORBIS_LIBRARIES}
${SAMPLERATE_LIBRARIES}
${SNDFILE_LIBRARIES}
${EXTRA_LIBRARIES}
)

IF(QT5)
TARGET_LINK_LIBRARIES(lmms
Qt5::Widgets
Qt5::Xml
)
ENDIF()



#
# rules for building localizations
#
FILE(GLOB lmms_LOCALES data/locale/*.ts)
SET(ts_targets "")
SET(qm_targets "")
FOREACH(_ts_file ${lmms_LOCALES})
STRING(REPLACE "${CMAKE_SOURCE_DIR}/data/locale/" "" _ts_target "${_ts_file}")
STRING(REPLACE ".ts" ".qm" _qm_file "${_ts_file}")
STRING(REPLACE ".ts" ".qm" _qm_target "${_ts_target}")
ADD_CUSTOM_TARGET(${_ts_target} COMMAND "${QT_LUPDATE_EXECUTABLE}" -locations none -no-obsolete -I ${CMAKE_SOURCE_DIR}/include/ ${LMMS_SRCS} ${LMMS_INCLUDES} ${LMMS_UIS} `find "\"${CMAKE_SOURCE_DIR}/plugins/\"" -type f -name '*.cpp' -or -name '*.h'` -ts "\"${_ts_file}\"")
ADD_CUSTOM_TARGET(${_qm_target} COMMAND "${QT_LRELEASE_EXECUTABLE}" "\"${_ts_file}\"" -qm "\"${_qm_file}\"")
LIST(APPEND ts_targets "${_ts_target}")
LIST(APPEND qm_targets "${_qm_target}")
ENDFOREACH(_ts_file ${lmms_LOCALES})

ADD_CUSTOM_TARGET(update-locales)
FOREACH(_item ${ts_targets})
ADD_DEPENDENCIES(update-locales "${_item}")
ENDFOREACH(_item ${ts_targets})

ADD_CUSTOM_TARGET(finalize-locales ALL)
FOREACH(_item ${qm_targets})
ADD_DEPENDENCIES(finalize-locales "${_item}")
ENDFOREACH(_item ${qm_targets})

# Install
IF(LMMS_BUILD_WIN32)

SET_TARGET_PROPERTIES(lmms PROPERTIES LINK_FLAGS "${LINK_FLAGS} -mwindows")
ADD_CUSTOM_COMMAND(TARGET lmms POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_BINARY_DIR}/lmms.exe\"")

INSTALL(TARGETS lmms RUNTIME DESTINATION "${BIN_DIR}")
INSTALL(FILES
"${MINGW_PREFIX}/bin/QtCore4.dll"
"${MINGW_PREFIX}/bin/QtGui4.dll"
"${MINGW_PREFIX}/bin/QtSvg4.dll"
"${MINGW_PREFIX}/bin/QtXml4.dll"
"${MINGW_PREFIX}/bin/libsamplerate-0.dll"
"${MINGW_PREFIX}/bin/libsndfile-1.dll"
"${MINGW_PREFIX}/bin/libvorbis-0.dll"
"${MINGW_PREFIX}/bin/libvorbisenc-2.dll"
"${MINGW_PREFIX}/bin/libvorbisfile-3.dll"
"${MINGW_PREFIX}/bin/libjpeg-9.dll"
"${MINGW_PREFIX}/bin/libogg-0.dll"
"${MINGW_PREFIX}/lib/libfltk.dll"
"${MINGW_PREFIX}/bin/libfluidsynth.dll"
"${MINGW_PREFIX}/bin/libfftw3f-3.dll"
"${MINGW_PREFIX}/bin/libFLAC-8.dll"
"${MINGW_PREFIX}/bin/libportaudio-2.dll"
"${MINGW_PREFIX}/bin/libpng16-16.dll"
"${MINGW_PREFIX}/bin/SDL.dll"
"${MINGW_PREFIX}/bin/libglib-2.0-0.dll"
"${MINGW_PREFIX}/bin/libgthread-2.0-0.dll"
"${MINGW_PREFIX}/bin/zlib1.dll"
"${MINGW_PREFIX}/${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32/bin/libwinpthread-1.dll"
DESTINATION .)

ELSE(LMMS_BUILD_WIN32)
IF(NOT LMMS_BUILD_APPLE)
SET_TARGET_PROPERTIES(lmms PROPERTIES LINK_FLAGS "${LINK_FLAGS} -Wl,-E")
ENDIF(NOT LMMS_BUILD_APPLE)

INSTALL(TARGETS lmms RUNTIME DESTINATION "${BIN_DIR}")
INSTALL(FILES "${CMAKE_BINARY_DIR}/lmms.1.gz" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1/" PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)

ENDIF(LMMS_BUILD_WIN32)
Loading

0 comments on commit ee3a998

Please sign in to comment.