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

Changes to compile on Mac #218

Merged
merged 7 commits into from
Aug 11, 2024
Merged
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
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ else()
endif()
set(COMPREHENSIVE_WARNING_FLAGS "-Wall -Wextra -Wpedantic -pedantic-errors -Werror -Wfatal-errors -Wno-psabi")
set(CMAKE_CXX_FLAGS "${MORPH_HOST_DEFINITION} -g ${COMPREHENSIVE_WARNING_FLAGS} -march=native -O3")
# Make it possible to compile complex constexpr functions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=5000000000")
endif()
else() # Windows
# Set flags for Windows. /EHsc required for use of exceptions
Expand Down Expand Up @@ -175,9 +177,6 @@ if(wxWidgets_FOUND)
endif()
endif()

# Make it possible to compile complex constexpr functions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=5000000000")

# rapidxml is bundled in the source, but its headers will be installed in ${CMAKE_INSTALL_PREFIX}/morph/, and they're symlinked in ${PROJECT_SOURCE_DIR}/morph
#include_directories("${PROJECT_SOURCE_DIR}/include/rapidxml-1.13")

Expand Down
100 changes: 58 additions & 42 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ if(ARMADILLO_FOUND)
target_link_libraries(grid_image GLEW::GLEW)
endif()

add_executable(grid_resampled_image grid_resampled_image.cpp)
target_link_libraries(grid_resampled_image OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(grid_resampled_image GLEW::GLEW)
# Like HexGrid::resampleImage, this one uses an omp call that only works on Mac with
# libomp, so avoid compiling this example on a Mac.
if(NOT APPLE)
add_executable(grid_resampled_image grid_resampled_image.cpp)
target_link_libraries(grid_resampled_image OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(grid_resampled_image GLEW::GLEW)
endif()
endif()

add_executable(grid_layout grid_layout.cpp)
Expand Down Expand Up @@ -215,16 +219,19 @@ if(USE_GLEW)
target_link_libraries(scatter GLEW::GLEW)
endif()

add_executable(scatter_ico scatter_ico.cpp)
target_link_libraries(scatter_ico OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(scatter_ico GLEW::GLEW)
endif()
# This sphere example uses constexpr code
if(NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
add_executable(scatter_ico scatter_ico.cpp)
target_link_libraries(scatter_ico OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(scatter_ico GLEW::GLEW)
endif()

add_executable(scatter_geodesic scatter_geodesic.cpp)
target_link_libraries(scatter_geodesic OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(scatter_geodesic GLEW::GLEW)
add_executable(scatter_geodesic scatter_geodesic.cpp)
target_link_libraries(scatter_geodesic OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(scatter_geodesic GLEW::GLEW)
endif()
endif()

add_executable(scatter_hex_mercator scatter_hex_mercator.cpp)
Expand Down Expand Up @@ -341,10 +348,13 @@ if(USE_GLEW)
target_link_libraries(rod GLEW::GLEW)
endif()

add_executable(grating grating.cpp)
target_link_libraries(grating OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(grating GLEW::GLEW)
# This example uses constexpr code
if(NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
add_executable(grating grating.cpp)
target_link_libraries(grating OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(grating GLEW::GLEW)
endif()
endif()

add_executable(cone cone.cpp)
Expand All @@ -353,36 +363,42 @@ if(USE_GLEW)
target_link_libraries(cone GLEW::GLEW)
endif()

add_executable(sphere sphere.cpp)
target_link_libraries(sphere OpenGL::GL glfw Freetype::Freetype)
set_property(TARGET sphere PROPERTY CXX_STANDARD 20)
if(USE_GLEW)
target_link_libraries(sphere GLEW::GLEW)
# This sphere example uses constexpr code
if(NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
add_executable(sphere sphere.cpp)
target_link_libraries(sphere OpenGL::GL glfw Freetype::Freetype)
set_property(TARGET sphere PROPERTY CXX_STANDARD 20)
if(USE_GLEW)
target_link_libraries(sphere GLEW::GLEW)
endif()
endif()

add_executable(icosahedron icosahedron.cpp)
target_link_libraries(icosahedron OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(icosahedron GLEW::GLEW)
endif()
# constexpr code won't work on Clang
if(NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
add_executable(icosahedron icosahedron.cpp)
target_link_libraries(icosahedron OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(icosahedron GLEW::GLEW)
endif()

# Need C++20 for the way I use constexpr here so that it is legal to
# have "a definition of a variable for which no initialization is
# performed".
add_executable(testce testce.cpp)
set_property(TARGET testce PROPERTY CXX_STANDARD 20)
# Need C++20 for the way I use constexpr here so that it is legal to
# have "a definition of a variable for which no initialization is
# performed".
add_executable(testce testce.cpp)
set_property(TARGET testce PROPERTY CXX_STANDARD 20)

add_executable(geodesic geodesic.cpp)
target_link_libraries(geodesic OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(geodesic GLEW::GLEW)
endif()
add_executable(geodesic geodesic.cpp)
target_link_libraries(geodesic OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(geodesic GLEW::GLEW)
endif()

add_executable(geodesic_ce geodesic_ce.cpp)
set_property(TARGET geodesic_ce PROPERTY CXX_STANDARD 20)
target_link_libraries(geodesic_ce OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(geodesic_ce GLEW::GLEW)
add_executable(geodesic_ce geodesic_ce.cpp)
set_property(TARGET geodesic_ce PROPERTY CXX_STANDARD 20)
target_link_libraries(geodesic_ce OpenGL::GL glfw Freetype::Freetype)
if(USE_GLEW)
target_link_libraries(geodesic_ce GLEW::GLEW)
endif()
endif()

add_executable(tri tri.cpp)
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <morph/Visual.h>
int main()
{
morph::Visual<morph::gl::version_3_1_es> v(600, 400, "Hello World!");
morph::Visual<morph::gl::version_4_1> v(600, 400, "Hello World!");
v.addLabel ("Hello World!", {0,0,0});
v.keepOpen();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion morph/AllocAndRead.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>
#include <sstream>
#include <fstream>
#include <cuchar>
#include <cstddef>
#include <stdexcept>
#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/BezCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <sstream>
#include <stdexcept>
#include <cmath>
#include <cuchar>
#include <cstddef>
#ifdef __ICC__
# define ARMA_ALLOW_FAKE_GCC 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion morph/ColourMap_Lists.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <cuchar>
#include <cstddef>

/*!
* Listed colour maps, copied from _cm_listed.py
Expand Down
2 changes: 1 addition & 1 deletion morph/HdfData.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <string>
#include <utility>
#include <bitset>
#include <cuchar>
#include <cstddef>
#include <sstream>
#include <stdexcept>
#include <morph/vec.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/MathAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <algorithm>
#include <bitset>
#include <memory>
#include <cuchar>
#include <cstddef>
#include <morph/vec.h>
#include <morph/vvec.h>
#include <morph/range.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/PointRowsVisual.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <iostream>
#include <vector>
#include <array>
#include <cuchar>
#include <cstddef>

namespace morph {

Expand Down
2 changes: 1 addition & 1 deletion morph/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>
#include <ostream>
#include <array>
#include <cuchar>
#include <cstddef>
#include <memory>

/*!
Expand Down
4 changes: 2 additions & 2 deletions morph/Scale.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include <stdexcept>
#include <cmath>
#include <cuchar>
#include <cstddef>
#include <string>
#include <sstream>
#include <morph/MathAlgo.h>
Expand Down Expand Up @@ -77,7 +77,7 @@ namespace morph {
* integers.
*/
template <typename T, typename S>
class ScaleImplBase
struct ScaleImplBase
{
public:
/*!
Expand Down
2 changes: 1 addition & 1 deletion morph/Visual.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#include <memory>
#include <functional>
#include <chrono>
#include <cuchar>
#include <cstddef>

#include <morph/VisualDefaultShaders.h>

Expand Down
2 changes: 1 addition & 1 deletion morph/VisualModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <string>
#include <memory>
#include <functional>
#include <cuchar>
#include <cstddef>

// Switches on some changes where I carefully unbind gl buffers after calling
// glBufferData() and rebind when changing the vertex model. Makes no difference on my
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/Basins.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <map>
#include <set>
#include <vector>
#include <cuchar>
#include <cstddef>

namespace morph {
namespace bn {
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/GeneNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <vector>
#include <bitset>
#include <list>
#include <cuchar>
#include <cstddef>
#include <math.h>
#include <immintrin.h> // Using intrinsics for computing Hamming distances
#include <morph/bn/Genome.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/GeneNetDual.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <morph/bn/Genome.h>
#include <morph/bn/GeneNet.h>
#include <set>
#include <cuchar>
#include <cstddef>

namespace morph {
namespace bn {
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/Genome.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <bitset>
#include <iostream>
#include <sstream>
#include <cuchar>
#include <cstddef>
#include <immintrin.h>
#include <morph/tools.h>
#include <morph/bn/Random.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/Genosect.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <cuchar>
#include <cstddef>

namespace morph {
namespace bn {
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/GradGenome.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <bitset>
#include <iostream>
#include <sstream>
#include <cuchar>
#include <cstddef>
#include <immintrin.h>
#include <morph/tools.h>
#include <morph/bn/Random.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/GradGenosect.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <cuchar>
#include <cstddef>

namespace morph {
namespace bn {
Expand Down
2 changes: 1 addition & 1 deletion morph/bn/Quine.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <sstream>
#include <string>
#include <vector>
#include <cuchar>
#include <cstddef>
#include <algorithm>
#include <morph/bn/Implicant.h>

Expand Down
2 changes: 1 addition & 1 deletion morph/bn/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <array>
#include <cuchar>
#include <cstddef>
#include <morph/Random.h>
#include <morph/bn/Genosect.h>

Expand Down
2 changes: 1 addition & 1 deletion morph/gl/compute_shaderprog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <vector>
#include <string>
#include <sstream>
#include <cuchar>
#include <cstddef>
#include <morph/gl/version.h>
#include <morph/gl/util.h>
#include <morph/vec.h>
Expand Down
4 changes: 2 additions & 2 deletions morph/gl/shaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ namespace morph {
if (morph::Tools::fileExists (entry.filename)) {
std::cout << "Using " << morph::gl::shader_type_str(entry.type)
<< " shader from the file " << entry.filename << std::endl;
source = std::move (morph::gl::ReadShader (entry.filename));
source = morph::gl::ReadShader (entry.filename);
} else {
if constexpr (debug_shaders == true) {
std::cout << "Using compiled-in " << morph::gl::shader_type_str(entry.type) << " shader\n";
}
source = std::move (morph::gl::ReadDefaultShader (entry.compiledIn));
source = morph::gl::ReadDefaultShader (entry.compiledIn);
}
if (source == nullptr) {
for (auto entry : shader_info) {
Expand Down
2 changes: 1 addition & 1 deletion morph/gl/ssbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Author: Seb James.
*/

#include <cuchar>
#include <cstddef>
#include <morph/vec.h>
#include <morph/vvec.h>
#include <morph/range.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/loadpng.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <type_traits>
#include <vector>
#include <string>
#include <cuchar>
#include <cstddef>
#include <stdexcept>
#include <morph/vec.h>
#include <morph/vvec.h>
Expand Down
2 changes: 1 addition & 1 deletion morph/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cuchar>
#include <cstddef>
#include <morph/Random.h>
#include <morph/range.h>

Expand Down
2 changes: 1 addition & 1 deletion morph/vvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cuchar>
#include <cstddef>
#include <morph/Random.h>
#include <morph/range.h>
#include <morph/trait_tests.h>
Expand Down
Loading