Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Subproject Changes #204

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to MinSizeRel.")
endif()

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake")
set(PDCURSES_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(PDCURSES_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Comment on lines +8 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, these two variables aren't necessary since CMake already automatically creates <PROJECT>_SOURCE_DIR and <PROJECT>_BINARY_DIR, in our case pdcurses_SOURCE_DIR and pdcurses_BINARY_DIR (notice the casing).

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include (get_version)
project(pdcurses VERSION "${CURSES_VERSION}" LANGUAGES C)
Expand Down Expand Up @@ -50,7 +52,9 @@ elseif(PDC_OS2_BUILD) # currently requires a unique toolchain file

else()

add_subdirectory(ncurses)
if (PDC_NCURSES_BUILD)
add_subdirectory(ncurses)
endif()

if(PDC_SDL2_BUILD)

Expand All @@ -63,15 +67,19 @@ else()
endif()

if(WIN32)

add_subdirectory(wincon)
add_subdirectory(wingui)
add_subdirectory(vt)

if (PDC_WINCON_BUILD)
add_subdirectory(wincon)
endif()
if (PDC_WINGUI_BUILD)
add_subdirectory(wingui)
endif()
if (PDC_VT_BUILD)
add_subdirectory(vt)
endif()
endif()

endif()

add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/make_uninstall.cmake")
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/make_uninstall.cmake")

set(CPACK_COMPONENTS_ALL applications)
2 changes: 1 addition & 1 deletion cmake/build_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ IF (PDC_SDL2_DEPS_BUILD)
URL https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-${SDL2_TTF_RELEASE}.zip
URL_HASH "SHA256=cdb72b5b1c3b27795fa128af36f369fee5d3e38a96c350855da0b81880555dbc"
PATCH_COMMAND cmake -E copy
${CMAKE_SOURCE_DIR}/cmake/sdl2_ttf/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2_ttf/CMakeLists.txt
${CMAKE_BINARY_DIR}/sdl2_ttf/CMakeLists.txt
UPDATE_COMMAND ""
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
Expand Down
12 changes: 12 additions & 0 deletions cmake/build_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ option(PDC_DOSVGA_BUILD "Build DOSVGA Project" OFF)
option(PDC_DOSVT_BUILD "Build VT Project" OFF)
option(PDC_SDL2_BUILD "Build SDL2 Project" ON)
option(PDC_SDL2_DEPS_BUILD "Build SDL2 and dependencies" ON)
option(PDC_NCURSES_BUILD "Build ncurses project" ON)
option(PDC_DEMOS_BUILD "Build demo applications" ON)
option(PDC_WINCON_BUILD "Build WinCon project" ON)
option(PDC_WINGUI_BUILD "Build WinGUI project" ON)
option(PDC_VT_BUILD "Build VT Win32 project" ON)
option(PDC_INSTALL_TARGETS "Provide install targets" ON)

message(STATUS "PDC_BUILD_SHARED ....... ${PDC_BUILD_SHARED}")
message(STATUS "PDC_UTF8 ............... ${PDC_UTF8}")
Expand All @@ -22,6 +28,12 @@ message(STATUS "PDC_DOSVGA_BUILD ....... ${PDC_DOSVGA_BUILD}")
message(STATUS "PDC_DOSVT_BUILD ........ ${PDC_DOSVT_BUILD}")
message(STATUS "PDC_SDL2_BUILD ......... ${PDC_SDL2_BUILD}")
message(STATUS "PDC_SDL2_DEPS_BUILD .... ${PDC_SDL2_DEPS_BUILD}")
message(STATUS "PDC_NCURSES_BUILD ...... ${PDC_NCURSES_BUILD}")
message(STATUS "PDC_DEMOS_BUILD ........ ${PDC_DEMOS_BUILD}")
message(STATUS "PDC_WINCON_BUILD ....... ${PDC_WINCON_BUILD}")
message(STATUS "PDC_WINGUI_BUILD ....... ${PDC_WINGUI_BUILD}")
message(STATUS "PDC_VT_BUILD ........... ${PDC_VT_BUILD}")
message(STATUS "PDC_INSTALL_TARGETS .... ${PDC_INSTALL_TARGETS}")

# normalize a windows path
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
4 changes: 2 additions & 2 deletions cmake/dll_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ endif()

set(PRODUCT_FILE_DESCRIPTION "${PRODUCT_FILE_DESCRIPTION} ${TOOL_NAME} ${TARGET_ARCH}")

configure_file ( ${CMAKE_SOURCE_DIR}/cmake/version.in.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY )
configure_file ( ${CMAKE_SOURCE_DIR}/cmake/resource.in.cmake ${CMAKE_CURRENT_BINARY_DIR}/resource.h @ONLY )
configure_file ( ${PDCURSES_SOURCE_DIR}/cmake/version.in.cmake ${PDCURSES_BINARY_DIR}/version.rc @ONLY )
configure_file ( ${PDCURSES_SOURCE_DIR}/cmake/resource.in.cmake ${PDCURSES_BINARY_DIR}/resource.h @ONLY )
2 changes: 1 addition & 1 deletion cmake/get_version.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

file(READ ${CMAKE_SOURCE_DIR}/curses.h _CURSES_H_CONTENTS)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/curses.h _CURSES_H_CONTENTS)

string(REGEX MATCH "#define PDC_VER_MAJOR ([a-zA-Z0-9_]+)" PDC_VER_MAJOR "${_CURSES_H_CONTENTS}")
string(REPLACE "#define PDC_VER_MAJOR " "" PDC_VER_MAJOR "${PDC_VER_MAJOR}")
Expand Down
54 changes: 31 additions & 23 deletions cmake/project_common.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
message(STATUS "**** ${PROJECT_NAME} ****")

set(PDCURSES_SRCDIR ${CMAKE_SOURCE_DIR})
set(PDCURSES_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR})
set(PDCURSES_DIST ${CMAKE_INSTALL_PREFIX}/${CMAKE_BUILD_TYPE})

set(osdir ${PDCURSES_SRCDIR}/${PROJECT_NAME})
set(osdir ${PDCURSES_SRCDIR})
set(demodir ${PDCURSES_SRCDIR}/demos)

set(pdc_src_files
Expand All @@ -22,7 +22,7 @@ include_directories (${osdir})

if(WIN32 AND NOT WATCOM)
include(dll_version)
list(APPEND pdc_src_files ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
list(APPEND pdc_src_files ${PDCURSES_BINARY_DIR}/version.rc)

add_definitions(-D_WIN32 -D_CRT_SECURE_NO_WARNINGS)

Expand Down Expand Up @@ -99,36 +99,44 @@ if(PDC_BUILD_SHARED)
target_link_libraries(${PDCURSE_PROJ} ${EXTRA_LIBS})
endif()

install(TARGETS ${PDCURSE_PROJ}
ARCHIVE DESTINATION ${PDCURSES_DIST}/lib/${PROJECT_NAME}
LIBRARY DESTINATION ${PDCURSES_DIST}/lib/${PROJECT_NAME}
RUNTIME DESTINATION ${PDCURSES_DIST}/bin/${PROJECT_NAME} COMPONENT applications)
if(PDC_INSTALL_TARGETS)
install(TARGETS ${PDCURSE_PROJ}
ARCHIVE DESTINATION ${PDCURSES_DIST}/lib/${PROJECT_NAME}
LIBRARY DESTINATION ${PDCURSES_DIST}/lib/${PROJECT_NAME}
RUNTIME DESTINATION ${PDCURSES_DIST}/bin/${PROJECT_NAME} COMPONENT applications)
endif()
set_target_properties(${PDCURSE_PROJ} PROPERTIES OUTPUT_NAME "pdcurses")
else()
set(PDCURSE_PROJ ${PROJECT_NAME}_pdcursesstatic)
add_library (${PDCURSE_PROJ} STATIC ${pdc_src_files} ${pdcurses_src_files})
install (TARGETS ${PDCURSE_PROJ} ARCHIVE DESTINATION ${PDCURSES_DIST}/lib/${PROJECT_NAME} COMPONENT applications)
if(PDC_INSTALL_TARGETS)
install (TARGETS ${PDCURSE_PROJ} ARCHIVE DESTINATION ${PDCURSES_DIST}/lib/${PROJECT_NAME} COMPONENT applications)
endif()
set_target_properties(${PDCURSE_PROJ} PROPERTIES OUTPUT_NAME "pdcursesstatic")
endif()

macro (demo_app dir targ)
set(bin_name "${PROJECT_NAME}_${targ}")
if(${targ} STREQUAL "tuidemo")
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tuidemo.c ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tui.c)
else()
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${targ}.c)
endif()
if (PDC_DEMOS_BUILD)
set(bin_name "${PROJECT_NAME}_${targ}")
if(${targ} STREQUAL "tuidemo")
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tuidemo.c ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tui.c)
else()
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${targ}.c)
endif()

add_executable(${bin_name} ${ARGV2} ${src_files})
add_executable(${bin_name} ${ARGV2} ${src_files})

if((${PROJECT_NAME} STREQUAL "wincon") OR (${PROJECT_NAME} STREQUAL "wingui"))
target_link_libraries(${bin_name} ${PDCURSE_PROJ} ${EXTRA_LIBS} ${WINCON_WINGUI_DEP_LIBS})
else()
target_link_libraries(${bin_name} ${PDCURSE_PROJ} ${EXTRA_LIBS})
endif()
if((${PROJECT_NAME} STREQUAL "wincon") OR (${PROJECT_NAME} STREQUAL "wingui"))
target_link_libraries(${bin_name} ${PDCURSE_PROJ} ${EXTRA_LIBS} ${WINCON_WINGUI_DEP_LIBS})
else()
target_link_libraries(${bin_name} ${PDCURSE_PROJ} ${EXTRA_LIBS})
endif()

add_dependencies(${bin_name} ${PDCURSE_PROJ})
set_target_properties(${bin_name} PROPERTIES OUTPUT_NAME ${targ})
add_dependencies(${bin_name} ${PDCURSE_PROJ})
set_target_properties(${bin_name} PROPERTIES OUTPUT_NAME ${targ})

install(TARGETS ${bin_name} RUNTIME DESTINATION ${PDCURSES_DIST}/bin/${PROJECT_NAME} COMPONENT applications)
if(PDC_INSTALL_TARGETS)
install(TARGETS ${bin_name} RUNTIME DESTINATION ${PDCURSES_DIST}/bin/${PROJECT_NAME} COMPONENT applications)
endif()
endif()
endmacro ()
4 changes: 2 additions & 2 deletions cmake/sdl2_ttf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ INSTALL (TARGETS SDL2_ttf
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
COMPONENT libraries)

ADD_EXECUTABLE (showfont ${CMAKE_SOURCE_DIR}/showfont.c)
ADD_EXECUTABLE (showfont ${CMAKE_CURRENT_SOURCE_DIR}/showfont.c)
TARGET_LINK_LIBRARIES (showfont SDL2_ttf ${SDL2_LIBRARIES} ${FT2_LIBRARY} ${ZLIB_LIBRARY} ${EXTRA_LIBS})
INSTALL (TARGETS showfont RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin COMPONENT applications)

ADD_EXECUTABLE (glfont ${CMAKE_SOURCE_DIR}/glfont.c)
ADD_EXECUTABLE (glfont ${CMAKE_CURRENT_SOURCE_DIR}/glfont.c)
TARGET_LINK_LIBRARIES (glfont SDL2_ttf ${SDL2_LIBRARIES} ${FT2_LIBRARY} ${ZLIB_LIBRARY} ${EXTRA_LIBS})
INSTALL (TARGETS glfont RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin COMPONENT applications)

Expand Down