diff --git a/.travis.yml b/.travis.yml index ff28f2db4..30b128f15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,7 +71,7 @@ matrix: - name: "linux focal gcc release fortran python" os: linux dist: focal - sudo: true + sudo: false env: - MAKE_FILE_GENERATOR="Unix Makefiles" - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Release" -DCMAKE_UNITY_BUILD_BATCH_SIZE=100000 # this is the strictest test for the unity build. @@ -86,6 +86,24 @@ matrix: - cmake - python3-setuptools + - name: "linux focal gcc debug fortran python STATIC" + os: linux + dist: focal + sudo: false + env: + - MAKE_FILE_GENERATOR="Unix Makefiles" + - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DWB_LIB_BUILD_SHARED=FALSE" + - MATRIX_EVAL="export PATH=/usr/bin/:$PATH" + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gfortran + - swig + - cmake + - python3-setuptools + - name: "windows debug VS 2017 python" os: windows language: cpp @@ -98,6 +116,18 @@ matrix: - FC=gfortran - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON" + - name: "windows debug VS 2017 python STATIC" + os: windows + language: cpp + env: + - MATRIX_EVAL="which gcc && choco install python --version=3.8.0 -y && choco install swig --version=4.0.1 -y" + - PYTHONPATH=C:/Python38/Lib + - PYTHONHOME=C:/Python38 + - PATH=C:/Python38:${PATH} + - MAKE_FILE_GENERATOR="Visual Studio 15 2017 Win64" + - FC=gfortran + - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DWB_LIB_BUILD_SHARED=FALSE" + - name: "windows release VS 2017 python" os: windows language: cpp @@ -192,14 +222,14 @@ matrix: - name: "linux trusty clang fortran python" os: linux - dist: trusty + dist: focal sudo: false os: linux compiler: - clang-3.6 env: - MAKE_FILE_GENERATOR="Unix Makefiles" - - MATRIX_EVAL="gfortran --version && CC=clang-3.6 && CXX=clang++-3.6 && GC=gfortran" + - MATRIX_EVAL="gfortran --version && CC=clang-3.6 && CXX=clang++-3.6 && GC=gfortran && export PATH=/usr/bin/:$PATH" - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Werror" addons: apt: @@ -213,6 +243,29 @@ matrix: - swig - python3-setuptools + - name: "linux trusty clang fortran python STATIC" + os: linux + dist: focal + sudo: false + os: linux + compiler: + - clang-3.6 + env: + - MAKE_FILE_GENERATOR="Unix Makefiles" + - MATRIX_EVAL="gfortran --version && CC=clang-3.6 && CXX=clang++-3.6 && GC=gfortran && export PATH=/usr/bin/:$PATH" + - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Werror -DWB_LIB_BUILD_SHARED=FALSE" + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + packages: + - clang-3.6 + - gfortran + - cmake + - swig + - python3-setuptools + - name: "osx clang fortran python" sudo: false os: osx @@ -240,12 +293,23 @@ matrix: os: osx compiler: - clang - osx_image: xcode11.6 + osx_image: xcode12 env: - MAKE_FILE_GENERATOR="Unix Makefiles" - MATRIX_EVAL="export PATH=$TRAVIS_ROOT/bin:$PATH && which clang && brew install swig || true" - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Werror" + - name: "osx clang fortran python STATIC" + sudo: false + os: osx + compiler: + - clang + osx_image: xcode12 + env: + - MAKE_FILE_GENERATOR="Unix Makefiles" + - MATRIX_EVAL="export PATH=$TRAVIS_ROOT/bin:$PATH && which clang && brew install swig || true" + - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Werror -DWB_LIB_BUILD_SHARED=FALSE" + - name: "windows debug mingw fortran" os: windows language: cpp @@ -268,12 +332,9 @@ matrix: os: linux dist: xenial sudo: false - compiler: - #- g++-6 env: - MAKE_FILE_GENERATOR="Unix Makefiles" - CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Release" - #- MATRIX_EVAL="gfortran --version && CC=gcc-6 && CXX=g++-6 && FC=gfortran" addons: apt: sources: diff --git a/CMakeLists.txt b/CMakeLists.txt index 73dd997b5..ff56c2a4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,6 @@ endif() set(SOURCES ${SOURCES_CXX} ${SOURCES_FORTAN}) -set(CMAKE_UNITY_BUILD_BATCH_SIZE 5000) # Special treatment of some files for unity builds. We disable the unity # build for them. @@ -173,7 +172,15 @@ FOREACH(_source_file ${UNITY_DISABLE_FILES}) SET_PROPERTY(SOURCE ${_source_file} PROPERTY SKIP_UNITY_BUILD_INCLUSION TRUE) ENDFOREACH() -add_library(WorldBuilder ${SOURCES}) +SET(WB_LIB_BUILD_SHARED ON CACHE BOOL "Whether to build and link a shared or static library version of the World Builder library.") + +if(${WB_LIB_BUILD_SHARED}) + add_library(WorldBuilder SHARED ${SOURCES}) + Message(STATUS "Build the World Builder library as a shared library.") +else() + add_library(WorldBuilder STATIC ${SOURCES}) + Message(STATUS "Build the World Builder library as a static library.") +endif() IF(NOT CMAKE_VERSION VERSION_LESS 3.16) SET(WB_UNITY_BUILD ON CACHE BOOL "Combine source files into less compile targets to speedup compile time. Currently only supported for cmake 3.16 and newer versions.") @@ -332,13 +339,16 @@ endif() # Make sure that the whole library is loaded, so the registration is done correctly. -if(NOT APPLE AND NOT MSVC) +if(WB_LIB_BUILD_SHARED) + SET(GWB_LIBRARY_WHOLE WorldBuilder) +elseif(NOT APPLE AND NOT MSVC) SET(GWB_LIBRARY_WHOLE -Wl,--whole-archive WorldBuilder -Wl,--no-whole-archive) elseif(MSVC) SET(GWB_LIBRARY_WHOLE WorldBuilder) else() SET(GWB_LIBRARY_WHOLE -Wl,-force_load WorldBuilder) endif() + target_link_libraries (WorldBuilderApp ${GWB_LIBRARY_WHOLE}) target_link_libraries (WorldBuilderVisualization ${GWB_LIBRARY_WHOLE}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a8cee6c21..5c7dc61ba 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,11 +47,12 @@ foreach(test_source ${UNIT_TEST_SOURCES}) endif() # Make sure that the whole library is loaded, so the registration is done correctly. - if(NOT APPLE) - SET(GWB_LIBRARY_WHOLE -Wl,--whole-archive WorldBuilder -Wl,--no-whole-archive) + if(WB_LIB_BUILD_SHARED) + SET(GWB_LIBRARY_WHOLE WorldBuilder) + elseif(NOT APPLE AND NOT MSVC) + SET(GWB_LIBRARY_WHOLE -Wl,--whole-archive WorldBuilder -Wl,--no-whole-archive) elseif(MSVC) SET(GWB_LIBRARY_WHOLE WorldBuilder) - SET(CMAKE_EXE_LINKER_FLAGS "/WHOLEARCHIVE:libworldbuilder") else() SET(GWB_LIBRARY_WHOLE -Wl,-force_load WorldBuilder) endif() @@ -154,15 +155,28 @@ endforeach(test_source) #test fortran compilation and wrapper if compiler found if(CMAKE_Fortran_COMPILER) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran) - if(NOT APPLE) - add_test(NAME compile_simple_fortran_test - COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/test.f90 -L../../lib/ -Wl,--whole-archive -lWorldBuilder -Wl,--no-whole-archive -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o test${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lstdc++ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + if(NOT APPLE) + if(${WB_LIB_BUILD_SHARED}) + add_test(NAME compile_simple_fortran_test + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/test.f90 -L../../lib/ -lWorldBuilder -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o test${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lstdc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + else() + add_test(NAME compile_simple_fortran_test + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/test.f90 -L../../lib/ -Wl,--whole-archive -lWorldBuilder -Wl,--no-whole-archive -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o test${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lstdc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + endif() else() - add_test(NAME compile_simple_fortran_test - COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/test.f90 -L../../lib/ -Wl,-force_load,../../lib/libWorldBuilder.a -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o test${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lc++ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + if(${WB_LIB_BUILD_SHARED}) + add_test(NAME compile_simple_fortran_test + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/test.f90 -L../../lib/ ../../lib/libWorldBuilder.so -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o test${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + else() + add_test(NAME compile_simple_fortran_test + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/test.f90 -L../../lib/ -Wl,-force_load,../../lib/libWorldBuilder.a -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o test${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + endif() endif() + add_test(run_simple_fortran_test ${CMAKE_COMMAND} -D TEST_NAME=run_simple_fortran_test @@ -174,15 +188,28 @@ if(CMAKE_Fortran_COMPILER) WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran) - if(NOT APPLE) - add_test(NAME compile_simple_fortran_example - COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/example.f90 -L../../lib/ -Wl,--whole-archive -lWorldBuilder -Wl,--no-whole-archive -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o example${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lstdc++ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + if(NOT APPLE) + if(${WB_LIB_BUILD_SHARED}) + add_test(NAME compile_simple_fortran_example + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/example.f90 -L../../lib/ -lWorldBuilder -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o example${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lstdc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + else() + add_test(NAME compile_simple_fortran_example + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/example.f90 -L../../lib/ -Wl,--whole-archive -lWorldBuilder -Wl,--no-whole-archive -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o example${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lstdc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + endif() else() - add_test(NAME compile_simple_fortran_example - COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/example.f90 -L../../lib/ -Wl,-force_load,../../lib/libWorldBuilder.a -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o example${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lc++ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + if(${WB_LIB_BUILD_SHARED}) + add_test(NAME compile_simple_fortran_example + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/example.f90 -L../../lib/ ../../lib/libWorldBuilder.so -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o example${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + else() + add_test(NAME compile_simple_fortran_example + COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fortran/example.f90 -L../../lib/ -Wl,-force_load,../../lib/libWorldBuilder.a -I../../mod/ ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -o example${CMAKE_EXECUTABLE_SUFFIX} ${WB_FORTRAN_COMPILER_FLAGS_COVERAGE} -lc++ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fortran/) + endif() endif() + add_test(run_simple_fortran_example ${CMAKE_COMMAND} -D TEST_NAME=run_simple_fortran_example diff --git a/tests/python/run_python_tests.cmake b/tests/python/run_python_tests.cmake index 3b30d6449..88c2f4bd0 100644 --- a/tests/python/run_python_tests.cmake +++ b/tests/python/run_python_tests.cmake @@ -20,7 +20,7 @@ set(EXECUTE_COMMAND ${TEST_PROGRAM} ${TEST_ARGS}) # run the test program, capture the stdout/stderr and the result var ${TEST_ARGS} execute_process( COMMAND ${TEST_PROGRAM} ${TEST_ARGS} -i ${TEST_INPUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fortran/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/ OUTPUT_FILE ${TEST_OUTPUT} ERROR_VARIABLE TEST_ERROR_VAR RESULT_VARIABLE TEST_RESULT_VAR