Skip to content

Commit

Permalink
Modern CMake, next try
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Feb 9, 2024
1 parent 739376a commit b9e0090
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 126 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/macos_fltk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,6 @@ jobs:
run: brew install clang-format
- name: Get sources
uses: actions/checkout@v4
- name: Get FLTK
uses: actions/checkout@v4
with:
repository: fltk/fltk
path: fltk
- name: Get newt64
uses: actions/checkout@v4
with:
repository: MatthiasWM/NEWT64
path: newt64
- name: Compile FLTK
run: |
cmake -S fltk -B fltk/build \
-D FLTK_USE_SYSTEM_LIBJPEG=Off \
-D FLTK_USE_SYSTEM_ZLIB=Off \
-D FLTK_USE_SYSTEM_LIBPNG=Off \
-D FLTK_BUILD_TEST=Off \
-D FLTK_BUILD_GL=Off
cmake --build fltk/build
sudo cmake --install fltk/build
- name: Compile newt64
run: |
cmake -S newt64 -B newt64/build
cmake --build newt64/build
sudo cmake --install newt64/build
- name: Configure Einstein
run: |
cmake -S . -B _Build_/Makefiles
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/mswindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,6 @@ jobs:
steps:
- name: Get sources
uses: actions/checkout@v4
- name: Get FLTK
uses: actions/checkout@v4
with:
repository: fltk/fltk
path: fltk
- name: Get newt64
uses: actions/checkout@v4
with:
repository: MatthiasWM/NEWT64
path: newt64
- name: Compile FLTK
run: |
cmake -S fltk -B fltk/build -D FLTK_USE_SYSTEM_LIBJPEG=Off -D FLTK_USE_SYSTEM_ZLIB=Off -D FLTK_USE_SYSTEM_LIBPNG=Off -D FLTK_BUILD_TEST=Off -D FLTK_BUILD_GL=Off -D CMAKE_BUILD_TYPE=Release
cmake --build fltk/build --config Release
- name: Compile newt64
run: |
cmake -S newt64 -B newt64/build -D CMAKE_BUILD_TYPE=Release
cmake --build newt64/build --config Release
- name: Configure
run: |
cmake -S . -B _Build_/Makefiles -D CMAKE_BUILD_TYPE=Release
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,6 @@ jobs:
sudo apt-get install clang-format-13
- name: Get sources
uses: actions/checkout@v4
- name: Get FLTK
uses: actions/checkout@v4
with:
repository: fltk/fltk
path: fltk
- name: Get newt64
uses: actions/checkout@v4
with:
repository: MatthiasWM/NEWT64
path: newt64
- name: Compile FLTK
run: |
cmake -S fltk -B fltk/build \
-D FLTK_USE_SYSTEM_LIBJPEG=Off \
-D FLTK_USE_SYSTEM_ZLIB=Off \
-D FLTK_USE_SYSTEM_LIBPNG=Off \
-D FLTK_BUILD_TEST=Off \
-D FLTK_BUILD_GL=Off
cmake --build fltk/build
sudo cmake --install fltk/build
- name: Compile newt64
run: |
cmake -S newt64 -B newt64/build
cmake --build newt64/build
sudo cmake --install newt64/build
- name: Configure Einstein
run: |
cmake -S . -B _Build_/Makefiles
Expand Down
116 changes: 58 additions & 58 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ include( CheckFunctionExists )
include( CheckIncludeFile )
include( FetchContent )

# ---- Setup Google Testing

FetchContent_Declare (
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set( gtest_force_shared_crt ON CACHE BOOL "" FORCE )

# Check if population has already been performed
FetchContent_GetProperties(googletest)
if ( NOT googletest_POPULATED )
# Fetch the content using previously declared details
FetchContent_Populate(googletest)

# Bring the populated content into the build
add_subdirectory( ${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} )
endif ()

enable_testing()

include( GoogleTest )

# ---- Configuration per platform

if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
Expand Down Expand Up @@ -86,56 +63,78 @@ endif ()
#
# ==== External Dependencies ===================================================
#
# ---- Newt/64 library ---------------------------------------------------------
# ---- Declare dependencies on outside content
#

if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
# Generates Newt64_FOUND, Newt64_DIR
find_package( Newt64 CONFIG HINTS ${CMAKE_CURRENT_SOURCE_DIR}/newt64/build )
endif()
FetchContent_Declare (
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
)

find_library ( newt64_lib NAMES newt64
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/newt64/build/Release
${CMAKE_CURRENT_SOURCE_DIR}/newt64/build/Debug
${CMAKE_CURRENT_SOURCE_DIR}/newt64/build
FetchContent_Declare(
FLTK
GIT_REPOSITORY https://github.com/fltk/fltk
GIT_TAG master
GIT_SHALLOW TRUE
)
find_file( newt64_incl NAMES NewtCore.h PATH_SUFFIXES newt64 HINTS ${CMAKE_CURRENT_SOURCE_DIR}/newt64/src/newt_core/incs )

if ( newt64_lib MATCHES ".*NOTFOUND" OR newt64_incl MATCHES ".*NOTFOUND" )
message( WARNING "Newt64 not found!" )
set( NEWT64_FOUND false )
else ()
set( NEWT64_FOUND true )
get_filename_component( newt64_lib_path ${newt64_lib} DIRECTORY )
get_filename_component( newt64_incl_path ${newt64_incl} DIRECTORY )
message( STATUS "Newt64 found in " ${newt64_lib_path} )
endif ()
FetchContent_Declare(
NEWT64
GIT_REPOSITORY https://github.com/MatthiasWM/NEWT64
GIT_TAG master
GIT_SHALLOW TRUE
)

#
# ---- FLTK library ------------------------------------------------------------
# ---- Setup Google Testing
#

# TODO: update this to automatically download and build in .../Einstein/fltk
set( FLTK_SKIP_OPENGL true )
find_program( LOCAL_FLTK_FLUID_EXECUTABLE fluid
HINTS
${CMAKE_SOURCE_DIR}/fltk/build/bin/Release
${CMAKE_SOURCE_DIR}/fltk/build/bin/Debug
${CMAKE_SOURCE_DIR}/fltk/build/bin
)
find_package( FLTK REQUIRED NO_MODULE HINTS ${CMAKE_SOURCE_DIR}/fltk/build )
# For Windows: Prevent overriding the parent project's compiler/linker settings
set( gtest_force_shared_crt ON CACHE BOOL "" FORCE )

if ( ${LOCAL_FLTK_FLUID_EXECUTABLE} MATCHES ".*NOTFOUND" )
message( WARNING "Fluid (FLTK User Interface Designer) not found!" )
else ()
message( STATUS "Fluid (FLTK User Interface Designer) found at " ${LOCAL_FLTK_FLUID_EXECUTABLE})
# Check if population has already been performed
FetchContent_GetProperties(googletest)
if ( NOT googletest_POPULATED )
# Fetch the content using previously declared details
FetchContent_Populate(googletest)

# Bring the populated content into the build
add_subdirectory( ${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} )
endif ()

enable_testing()

include( GoogleTest )

#
# ---- Newt/64 library ---------------------------------------------------------
#

message(STATUS "Downloading and configuring NEWT64 if necessary, please wait...")
FetchContent_MakeAvailable(NEWT64)
message(STATUS "Downloading and configuring NEWT64 - done.")
# Newt64_BINARY_DIR
set( NEWT64_FOUND true )

#
# ---- FLTK library ------------------------------------------------------------
#

message(STATUS "Downloading and configuring FLTK if necessary, please wait...")
set( FLTK_USE_SYSTEM_LIBJPEG OFF )
set( FLTK_USE_SYSTEM_ZLIB OFF )
set( FLTK_USE_SYSTEM_LIBPNG OFF )
set( FLTK_BUILD_TEST OFF )
set( FLTK_BUILD_GL OFF )
set( FLTK_BUILD_FORMS OFF )
set( FLTK_BUILD_FLTK_OPTIONS OFF )
FetchContent_MakeAvailable(FLTK)
message(STATUS "Downloading and configuring FLTK - done.")

function ( build_with_fluid name dir )
add_custom_command (
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/${dir}"
COMMAND ${LOCAL_FLTK_FLUID_EXECUTABLE} -c ${name}.fl
COMMAND fltk::fluid -c ${name}.fl
DEPENDS "${CMAKE_SOURCE_DIR}/${dir}/${name}.fl"
DEPENDS "${ARGN}"
OUTPUT "${CMAKE_SOURCE_DIR}/${dir}/${name}.cpp"
Expand Down Expand Up @@ -238,6 +237,7 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
target_link_libraries ( Einstein
${system_libs}
fltk::fltk fltk::images fltk::png fltk::z
libnewt64
pthread
"-framework AddressBook"
"-framework AudioUnit"
Expand Down

0 comments on commit b9e0090

Please sign in to comment.