more work on makefiles/cmake.cpp

This commit is contained in:
Laurent Perron
2022-02-19 15:05:17 +01:00
parent cd269c63dc
commit 0266492da6
4 changed files with 23 additions and 17 deletions

View File

@@ -2,6 +2,8 @@ if(NOT BUILD_CXX)
return()
endif()
# Main Target
add_library(${PROJECT_NAME} "")
# Xcode fails to build if library doesn't contains at least one source file.
@@ -95,13 +97,23 @@ target_include_directories(${PROJECT_NAME} INTERFACE
$<INSTALL_INTERFACE:include>
)
if (win32)
set(cxx_compile_feature "cxx_std_20")
else()
set(cxx_compile_feature "cxx_std_17")
endif()
# Compile options
set_target_properties(${PROJECT_NAME} PROPERTIES
if(WIN32)
CXX_STANDARD 20
else()
CXX_STANDARD 17
endif()
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_compile_features(${PROJECT_NAME} PUBLIC ${cxx_compile_feature})
target_compile_definitions(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS})
target_compile_options(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})
@@ -320,7 +332,7 @@ function(add_cxx_sample FILE_NAME)
add_executable(${SAMPLE_NAME} ${FILE_NAME})
target_include_directories(${SAMPLE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${SAMPLE_NAME} PRIVATE cxx_std_17)
target_compile_features(${SAMPLE_NAME} PRIVATE ${cxx_compile_feature})
target_link_libraries(${SAMPLE_NAME} PRIVATE ${PROJECT_NAMESPACE}::ortools)
include(GNUInstallDirs)
@@ -353,7 +365,7 @@ function(add_cxx_example FILE_NAME)
add_executable(${EXAMPLE_NAME} ${FILE_NAME})
target_include_directories(${EXAMPLE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${EXAMPLE_NAME} PRIVATE cxx_std_17)
target_compile_features(${EXAMPLE_NAME} PRIVATE ${cxx_compile_feature})
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${PROJECT_NAMESPACE}::ortools)
include(GNUInstallDirs)
@@ -386,7 +398,7 @@ function(add_cxx_test FILE_NAME)
add_executable(${TEST_NAME} ${FILE_NAME})
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${TEST_NAME} PRIVATE cxx_std_17)
target_compile_features(${TEST_NAME} PRIVATE ${cxx_compile_feature})
target_link_libraries(${TEST_NAME} PRIVATE ${PROJECT_NAMESPACE}::ortools)
if(BUILD_TESTING)

View File

@@ -42,10 +42,10 @@ or_tools_libs: $(OR_TOOLS_LIBS)
or-tools-libs: $(OR_TOOLS_LIBS)
# OR Tools unique library.
$(OR_TOOLS_LIBS): dependencies/CMakeCache.txt
$(OR_TOOLS_LIBS): third_party
cmake --build dependencies --target install -j 8
cc: dependencies/CMakeCache.txt
cc: third_party
cmake --build dependencies --target install -j 8
test_cc: \

View File

@@ -22,7 +22,7 @@ third_party: build_third_party
.PHONY: build_third_party
build_third_party: \
Makefile.local \
cmake_third_party
dependencies/Makefile
######################
## Makefile.local ##
@@ -59,9 +59,7 @@ Makefile.local: makefiles/Makefile.third_party.$(SYSTEM).mk
dependencies:
mkdir dependencies
cmake_third_party: dependencies/CMakeCache.txt
dependencies/CMakeCache.txt: | dependencies
dependencies/Makefile: | dependencies
cmake -S . -B dependencies -DBUILD_DEPS=ON -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DUSE_COINOR=$(USE_COINOR) -DUSE_SCIP=$(USE_SCIP) -DUSE_GLPK=$(USE_GLPK) -DCMAKE_INSTALL_PREFIX=$(OR_ROOT_FULL)
.PHONY: clean_third_party # Clean everything. Remember to also delete archived dependencies, i.e. in the event of download failure, etc.

View File

@@ -14,8 +14,7 @@ SWIG_BINARY = "$(OR_TOOLS_TOP)\\bin\\swig.exe"
.PHONY: third_party # Build OR-Tools Prerequisite
third_party: \
Makefile.local \
cmake_third_party
dependencies/ortools.sln
######################
## Makefile.local ##
@@ -48,11 +47,8 @@ Makefile.local: makefiles/Makefile.third_party.$(SYSTEM).mk
@echo # Paths must be without spaces, try to use 'dir "directory*" /x' to get the shortname without space of each directory >> Makefile.local
@echo # e.g. dir "%ProgramFiles%*" /x >> Makefile.local
cmake_third_party: dependencies/CMakeCache.txt
dependencies/CMakeCache.txt: | dependencies
cmake -S . -B dependencies -DBUILD_DEPS=ON -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DUSE_COINOR=$(USE_COINOR) -DUSE_SCIP=$(USE_SCIP) -DUSE_GLPK=$(USE_GLPK) -DCMAKE_INSTALL_PREFIX=$(OR_ROOT_FULL)
dependencies/ortools.sln: | dependencies
cmake -S . -B dependencies -DBUILD_DEPS=ON -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DUSE_COINOR=$(USE_COINOR) -DUSE_SCIP=$(USE_SCIP) -DUSE_GLPK=$(USE_GLPK) -DCMAKE_INSTALL_PREFIX=$(OR_ROOT_FULL) -DCMAKE_BUILD_TYPE=Release
.PHONY: clean_third_party # Clean everything. Remember to also delete archived dependencies, i.e. in the event of download failure, etc.
clean_third_party: