Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProMod3
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
ProMod3
Commits
f2998110
Commit
f2998110
authored
11 years ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Playing around with CMake
parent
b05d6869
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
cmake_support/PROMOD3.cmake
+71
-65
71 additions, 65 deletions
cmake_support/PROMOD3.cmake
with
72 additions
and
65 deletions
CMakeLists.txt
+
1
−
0
View file @
f2998110
...
...
@@ -65,6 +65,7 @@ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
## e.g. add_subdirectory(src), subdirs have thier own CMakeLists.txt
add_subdirectory
(
config
)
add_subdirectory
(
meld
)
add_subdirectory
(
scripts
)
## report setup
message
(
STATUS
"PROMOD3 will be built with the following options:
\n
"
...
...
This diff is collapsed.
Click to expand it.
cmake_support/PROMOD3.cmake
+
71
−
65
View file @
f2998110
...
...
@@ -506,28 +506,28 @@ macro(pymod)
#-----------------------------------------------------------------------------
set
(
_ARG_PREFIX promod3
)
parse_argument_list
(
_ARG
"NAME;CPP;PY;LINK;OUTPUT_DIR;
UI;
PREFIX"
""
${
ARGN
}
)
"NAME;CPP;PY;LINK;OUTPUT_DIR;PREFIX"
""
${
ARGN
}
)
if
(
NOT _ARG_NAME
)
message
(
FATAL_ERROR
"invalid use of pymod(): a name must be provided"
)
endif
()
if
(
ENABLE_STATIC
)
return
()
endif
()
if
(
_ARG_OUTPUT_DIR
)
set
(
PYMOD_DIR
"python
${
PYTHON_VERSION
}
/site-packages/
${
_ARG_OUTPUT_DIR
}
"
)
set
(
PYMOD_DIR
"python
${
PYTHON_VERSION
}
/site-packages/
promod3/
${
_ARG_OUTPUT_DIR
}
"
)
else
()
set
(
PYMOD_DIR
"python
${
PYTHON_VERSION
}
/site-packages/
${
_ARG_PREFIX
}
/
${
_ARG_NAME
}
"
)
if
(
_ARG_PREFIX
)
set
(
PYMOD_DIR
"python
${
PYTHON_VERSION
}
/site-packages/promod3/
${
_ARG_PREFIX
}
/
${
_ARG_NAME
}
"
)
else
()
set
(
PYMOD_DIR
"python
${
PYTHON_VERSION
}
/site-packages/promod3/
${
_ARG_NAME
}
"
)
endif
()
endif
()
set
(
_LIB_NAME
${
_ARG_PREFIX
}
_
${
_ARG_NAME
}
)
set
(
PYMOD_STAGE_DIR
"
${
LIB_STAGE_PATH
}
/
${
PYMOD_DIR
}
"
)
file
(
MAKE_DIRECTORY
${
PYMOD_STAGE_DIR
}
)
include_directories
(
${
PYTHON_INCLUDE_PATH
}
)
#-----------------------------------------------------------------------------
# compile and link C++ wrappers
#-----------------------------------------------------------------------------
if
(
_ARG_CPP
)
add_library
(
"_
${
_
LIB
_NAME
}
"
MODULE
${
_ARG_CPP
}
)
set_target_properties
(
"_
${
_
LIB
_NAME
}
"
add_library
(
"_
${
_
ARG
_NAME
}
"
MODULE
${
_ARG_CPP
}
)
set_target_properties
(
"_
${
_
ARG
_NAME
}
"
PROPERTIES ECHO_STRING
"Building Python Module
${
_ARG_NAME
}
"
)
if
(
_ARG_PREFIX
)
...
...
@@ -537,78 +537,84 @@ macro(pymod)
endif
()
get_target_property
(
_CUSTOM_CHECK
"
${
_PARENT_NAME
}
"
HEADER_ONLY
)
if
(
NOT _CUSTOM_CHECK
)
set
(
_PARENT_
LIB
_NAME
"
${
_PARENT_NAME
}
"
)
set
(
_PARENT_
ARG
_NAME
"
${
_PARENT_NAME
}
"
)
endif
()
target_link_libraries
(
"_
${
_
LIB
_NAME
}
"
${
_PARENT_
LIB
_NAME
}
target_link_libraries
(
"_
${
_
ARG
_NAME
}
"
${
_PARENT_
ARG
_NAME
}
${
PYTHON_LIBRARIES
}
${
BOOST_PYTHON_LIBRARIES
}
)
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${
PYMOD_STAGE_DIR
}
)
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE
${
PYMOD_STAGE_DIR
}
)
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG
${
PYMOD_STAGE_DIR
}
)
if
(
NOT ENABLE_STATIC
)
if
(
_USE_RPATH
)
string
(
REGEX REPLACE
"/[^/]*"
"/.."
inv_pymod_path
"/
${
PYMOD_DIR
}
"
)
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES INSTALL_RPATH
"$ORIGIN
${
inv_pymod_path
}
/"
)
else
()
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES INSTALL_RPATH
""
)
endif
()
endif
()
set_target_properties
(
"_
${
_ARG_NAME
}
"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${
PYMOD_STAGE_DIR
}
INSTALL_NAME_DIR
"@rpath"
)
if
(
APPLE
)
file
(
RELATIVE_PATH _REL_PATH
"
${
PYMOD_STAGE_DIR
}
"
"
${
LIB_STAGE_PATH
}
"
)
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES
LINK_FLAGS
"-Wl,-rpath,@loader_path/
${
_REL_PATH
}
"
INSTALL_NAME_DIR
"@rpath"
)
set_target_properties
(
_
${
_ARG_NAME
}
PROPERTIES
LINK_FLAGS
"-Wl,-rpath,@
${
_REL_PATH
}
"
)
endif
()
set_target_properties
(
"_
${
_LIB_NAME
}
"
PROPERTIES PREFIX
""
)
install
(
TARGETS
"_
${
_LIB_NAME
}
"
LIBRARY DESTINATION
if
(
NOT WIN32
)
set_target_properties
(
"_
${
_ARG_NAME
}
"
PROPERTIES PREFIX
""
)
else
()
set_target_properties
(
"_
${
_ARG_NAME
}
"
PROPERTIES PREFIX
"../"
)
set_target_properties
(
"_
${
_ARG_NAME
}
"
PROPERTIES SUFFIX
".pyd"
)
endif
()
install
(
TARGETS
"_
${
_ARG_NAME
}
"
LIBRARY DESTINATION
"
${
LIB_DIR
}
/
${
PYMOD_DIR
}
"
)
else
()
add_custom_target
(
"_
${
_
LIB
_NAME
}
"
ALL
)
add_custom_target
(
"_
${
_
ARG
_NAME
}
"
ALL
)
endif
()
#-----------------------------------------------------------------------------
# build ui files
#-----------------------------------------------------------------------------
if
(
_ARG_UI
)
ui_to_python
(
${
_LIB_NAME
}
${
PYMOD_DIR
}
${
PYMOD_STAGE_DIR
}
${
_ARG_UI
}
)
endif
()
#-----------------------------------------------------------------------------
# compile python files
#-----------------------------------------------------------------------------
if
(
_ARG_PY
)
parse_file_list
(
"
${
_ARG_PY
}
"
_PYFILE_MAP
)
map
(
KEYS _PYFILE_MAP _PYFILE_MAP_KEYS
)
foreach
(
_DIR
${
_PYFILE_MAP_KEYS
}
)
map
(
GET _PYFILE_MAP
${
_DIR
}
_PY_FILES
)
set
(
_ABS_PY_FILES
)
set
(
_PY_SOURCE_DIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
_DIR
}
"
)
foreach
(
_PY
${
_PY_FILES
}
)
list
(
APPEND _ABS_PY_FILES
"
${
_PY_SOURCE_DIR
}
/
${
_PY
}
"
)
endforeach
()
install
(
FILES
${
_ABS_PY_FILES
}
DESTINATION
"
${
LIB_DIR
}
/
${
PYMOD_DIR
}
/
${
_DIR
}
"
)
string
(
REPLACE
"/"
"_"
_DIR_NO_SLASH
"
${
_DIR
}
"
)
set
(
_PYMOD_TARGET
"
${
_LIB_NAME
}
_
${
_DIR_NO_SLASH
}
_pymod"
)
string
(
REPLACE
"_."
""
_PYMOD_TARGET
"
${
_PYMOD_TARGET
}
"
)
add_custom_target
(
${
_PYMOD_TARGET
}
ALL
)
copy_if_different
(
"./"
"
${
PYMOD_STAGE_DIR
}
/
${
_DIR
}
"
"
${
_ABS_PY_FILES
}
"
"TARGETS"
"
${
_PYMOD_TARGET
}
"
)
compile_py_files
(
_
${
_LIB_NAME
}
${
PYMOD_STAGE_DIR
}
/
${
_DIR
}
compiled_files
${
_ABS_PY_FILES
}
)
install
(
FILES
${
compiled_files
}
DESTINATION
"
${
LIB_DIR
}
/
${
PYMOD_DIR
}
/
${
_DIR
}
"
)
set
(
_PY_FILES
)
set
(
_EXPECT_IN_DIR FALSE
)
foreach
(
_PY_FILE
${
_ARG_PY
}
)
if
(
_PY_FILE STREQUAL
"IN_DIR"
)
set
(
_EXPECT_IN_DIR TRUE
)
else
()
if
(
_EXPECT_IN_DIR
)
set
(
_EXPECT_IN_DIR FALSE
)
set
(
_DIR
${
_PY_FILE
}
)
set
(
_ABS_PY_FILES
)
set
(
_PY_SOURCE_DIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
_DIR
}
"
)
foreach
(
_PY
${
_PY_FILES
}
)
list
(
APPEND _ABS_PY_FILES
"
${
_PY_SOURCE_DIR
}
/
${
_PY
}
"
)
endforeach
()
install
(
FILES
${
_ABS_PY_FILES
}
DESTINATION
"
${
LIB_DIR
}
/
${
PYMOD_DIR
}
/
${
_DIR
}
"
)
string
(
REPLACE
"/"
"_"
_DIR_NO_SLASH
"
${
_DIR
}
"
)
add_custom_target
(
"
${
_ARG_NAME
}
_
${
_DIR_NO_SLASH
}
_pymod"
ALL
)
copy_if_different
(
"./"
"
${
PYMOD_STAGE_DIR
}
/
${
_DIR
}
"
"
${
_ABS_PY_FILES
}
"
"TARGETS"
"
${
_ARG_NAME
}
_
${
_DIR_NO_SLASH
}
_pymod"
)
set
(
_PY_FILES
)
else
()
list
(
APPEND _PY_FILES
"
${
_PY_FILE
}
"
)
endif
()
endif
()
endforeach
()
if
(
_PY_FILES
)
add_custom_target
(
"
${
_ARG_NAME
}
_pymod"
ALL
)
#add_custom_target("${_LIB_NAME}_pymod" ALL)
copy_if_different
(
"./"
"
${
PYMOD_STAGE_DIR
}
"
"
${
_ABS_PY_FILES
}
"
"TARGETS"
"
${
_ARG_NAME
}
_pymod"
)
#add_dependencies("_${_LIB_NAME}" "${_LIB_NAME}_pymod")
add_dependencies
(
"_
${
_ARG_NAME
}
"
"
${
_ARG_NAME
}
_pymod"
)
#copy_if_different("./" "${PYMOD_STAGE_DIR}" "${_PY_FILES}" "TARGETS"
# "${_ARG_NAME}_pymod")
include_directories
(
${
PYTHON_INCLUDE_PATH
}
)
install
(
FILES
${
_PY_FILES
}
DESTINATION
"
${
LIB_DIR
}
/
${
PYMOD_DIR
}
"
)
endif
()
endif
()
get_target_property
(
_MOD_DEPS
"
${
_PARENT_NAME
}
"
MODULE_DEPS
)
if
(
_MOD_DEPS
)
foreach
(
dep
${
_MOD_DEPS
}
)
add_dependencies
(
"_
${
_
LIB
_NAME
}
"
"_
${
dep
}
"
)
add_dependencies
(
"_
${
_
ARG
_NAME
}
"
"_
${
dep
}
"
)
endforeach
()
endif
()
endmacro
()
add_custom_target
(
check
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment